Skip to content

Empty menuOptions should hide their buttons #11

@AdamFipke

Description

@AdamFipke

In my use case where I'm using this as a video file explorer, I want to disable a lot of the actions. I can do this through menuOptions by making it an empty array (as mentioned in the docs), but the buttons that would open the context menu still exist despite them not having a reason to (see examples below).

Here is my menuOptions.

  const menuOptions = (mode: TContextMenuType, item: IParsedEntity | undefined): IFileMenuOption[] => {
    switch (mode) {
      case "folder":
        return []
      case "multiselect":
        return [
          {
            icon: "wxi-close",
            text: "Delete",
            hotkey: "Delete",
            id: "delete",
          },
        ]
      case "body":
        return []
      case "add":
        return []
      case "file":
        return [
          {
            icon: "",
            text: "Open Video",
            hotkey: "Ctrl+I",
            comp: () => {
              return (
                item && (
                  <a href={`https://stream.mux.com/${item.playbackId}.m3u8`} target="_blank" rel="noopener noreferrer">
                    Open Video
                  </a>
                )
              )
            },
            id: "open-video",
          },
          {
            icon: "wxi-edit",
            text: "Edit Title",
            hotkey: "Ctrl+R",
            id: "rename",
          },
          {
            icon: "wxi-close",
            text: "Delete",
            hotkey: "Delete",
            id: "delete",
          },
        ]
      default:
        return getMenuOptions(mode)
    }
  }

Examples

case "folder":
        return []

This leaves a leftover ... button at the bottom right. Clicking this does nothing. (also ignore the fact that the filemanager is pink and has a duration an item count on the preview image, that's just me ;P).
Image

      case "add":
        return []

The "Add New" button will still be there despite nothing happening when you click it.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions