Skip to content

ContextMenuGroup

Submenu component.

Props

PropertyDescriptionTypeDefault
labelThe label of menu.string
iconThe icon for menu item.string
iconFontClassCustom icon library font class name.stringiconfont
preserveIconWidthShould a fixed-width icon area be reserved for menu items without icon.booleantrue
svgIconDisplay icons use svg symbol (<use xlink:href="...">) , only valid when icon attribute is empty.string
svgPropsThe user-defined attribute of the svg tag, which is valid when using svgIcon.SVGAttributes
disabledDisable menu item?booleanfalse
checkedIs this menu item checked?booleanfalse
shortcutShortcut key text display on the right. The shortcut keys here are only for display. You need to handle the key events by yourself.string''
clickableWhenHasChildrenWhen there are subitems in this item, is it allowed to trigger its own click event?booleanfalse
adjustSubMenuPositionBy default, the submenu will automatically adjust its position to prevent it overflow the container. If you allow menu overflow containers, you can set this to false.booleaninherit from MenuOptions.adjustPosition
clickCloseShould close menu when Click this menu item ?booleantrue
customClassCustom submenu class.string
minWidthSubmenu minimum width (in pixels).number100
maxWidthSubmenu maximum width (in pixels).number600
onClickMenu item click event handler.Function()

Slots

Slot nameDescriptionArguments
defaultSubmenu render slot-

ContextMenuGroupRef

getSubMenuRef(): ContextSubMenuInstance

Get ContextSubMenuInstance of this group

Returns

Explain
ContextSubMenuInstance

getMenuItemRef(): MenuItemContext

Get MenuItemContext of this item.

Returns

Explain
MenuItemContext

ContextSubMenuInstance

Define that Submenu holder component exposed props. Use it to control more complex controls of the menu, including getting menu items, getting height, position, scrolling, setting scroll values, position, and more.

Can get by ContextMenuInstance.getMenuRef.

getSubmenuRoot(): HTMLElement

Get Root element of this submenu.

getMenu(): HTMLElement

Get Inner container element of this submenu.

getChildItem(index: number) : MenuItemContext | undefined

Get child menu item by array index, Only after the parent submenu is displayed can the child items be retrieved.

Param

ParamExplain
indexArray index

Rturns

Explain
You can obtain control instance MenuItemContext according to the index to control menu items.

getMenuDimensions(): { width: number, height: number }

Get submenu root element size.

Returns

Explain
Return root menu size in pixel, return all zero if menu is not showing.

getScrollValue(): number

Get submenu current scroll value (same as element.scrollTop).

getScrollHeight(): number

Get submenu max scroll height (same as element.scrollHeight).

getMaxHeight(): number

Get max submenu height.

getPosition(): { width: number, height: number }

Get submenu current position (Relative to the parent item).

setScrollValue(v: number): void

Set submenu current scroll value (same as element.scrollTop).

Param

ParamExplain
velement.scrollTop

setPosition(x: number, y: number): void

Set submenu current position (Relative to the parent item).

Param

ParamExplain
xX position
yY position

Released under the MIT License.