Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ContextMenuHookOptions

remarks

@since 5.0.0

Hierarchy

Index

Properties

anchor?: PositionAnchor

The PositionAnchor to use for the menu. Here's the default value for the anchor:

  • horizontal - BELOW_CENTER_ANCHOR
  • a submenu - TOP_RIGHT_ANCHOR
  • default - TOP_INNER_RIGHT_ANCHOR
baseId?: string

Since there can generally only be one context menu visible at a time, this will be defaulted to "context-menu" instead of requiring an id like the useMenu hook. If the default id does not work for your use case, it can still be overridden.

defaultvalue

"context-menu"

see

BaseMenuHookOptions.baseId

closeOnResize?: boolean

Boolean if the menu should close instead of repositioning itself if the browser window is resized.

defaultvalue

false

closeOnScroll?: boolean

Boolean if the menu should close if the page is scrolled. The default behavior is to just update the position of the menu relative to the menu button until it can no longer be visible within the viewport.

defaultvalue

false

disableFocusOnMount?: boolean

Boolean if the menu component should not gain focus once it has mounted. This should really only be set to true if the enter transition has been disabled.

defaultvalue

timeout === 0

disableFocusOnUnmount?: boolean

Boolean if the toggle element should no longer gain focus when the menu loses visibility.

Note: The toggle element will not gain focus if:

  • the menu closed via resizing the browser window
  • the menu closes because the menu is no longer within the viewport
  • the current document.activeElement has moved outside of the menu
    • this generally means the MenuItem's action cause the focus to move already
  • the current document.activeElement is an link (<a href="">)
    • links should generally handle focus behavior themselves
defaultvalue

timeout === 0

fixedPositionOptions?: Readonly<CalculateFixedPositionOptions>

{@inheritDoc CalculateFixedPositionOptions}

horizontal?: boolean

Boolean if the menu should be rendered horizontally instead of vertically. This will also update the aria-orientation.

defaultvalue

false

menuLabel?: string

The label should be required for a context menu since there is no valid "toggle" component here to inherit a label from. However, this will be defaulted to "Context Menu" for convenience.

defaultvalue

"Context Menu"

see

BaseMenuHookOptions.menuLabel

menuitem?: boolean

Boolean if the menu is being rendered as a menuitem instead of a button. Setting this to true implements the ProvidedMenuToggleProps.onKeyDown functionality.

defaultvalue

false

onEnter?: TransitionEnterHandler

This function will be called once the TransitionStage has been set to "enter".

see

TransitionEnterHandler

onEntered?: TransitionEnterHandler

This function will be called once the TransitionStage has been set to "entering".

see

TransitionEnterHandler

onEntering?: TransitionEnterHandler

This function will be called once the TransitionStage has been set to "enter".

see

TransitionEnterHandler

onExited?: TransitionExitHandler

This function will be called once the TransitionStage has been set to "exited".

see

TransitionExitHandler

onFixedPositionResize?: EventListener

An optional function to call if the page resizes while the menu is visible.

onFixedPositionScroll?: TransitionScrollCallback<HTMLElement, HTMLDivElement>

{@inheritDoc TransitionScrollCallback}

preventScroll?: boolean

Unlike other menus, context menus will default to no longer allowing the page to be scrolled while visible.

see

BaseMenuHookOptions.preventScroll

defaultvalue

true.

style?: CSSProperties

An optional style object to merge with the Menu's fixed positioning style.

see

useFixedPositioning

see

FixedPositionStyle

Methods

  • getFixedPositionOptions(): Readonly<CalculateFixedPositionOptions>
  • onContextMenu<E>(event: MouseEvent<E, MouseEvent>): void
  • An optional custom contextmenu event handler that will be merged with the menu visibility behavior. If this function calls event.stopPropagation(), the default context menu behavior will not occur.

    Type parameters

    • E: HTMLElement

    Parameters

    • event: MouseEvent<E, MouseEvent>

    Returns void

Generated using TypeDoc