Skip to content

Commit

Permalink
docs(ui5-menu): make focus event public (#8407)
Browse files Browse the repository at this point in the history
  • Loading branch information
unazko authored Mar 8, 2024
1 parent 012fc4d commit d5e5944
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion packages/main/src/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ type MenuItemClickEventDetail = {
type MenuBeforeOpenEventDetail = { item?: MenuItem };
type MenuBeforeCloseEventDetail = { escPressed: boolean };

type MenuItemFocusEventDetail = {
ref: HTMLElement,
item: MenuItem,
};

type OpenerStandardListItem = StandardListItem & { associatedItem: MenuItem };

/**
Expand Down Expand Up @@ -184,6 +189,32 @@ type OpenerStandardListItem = StandardListItem & { associatedItem: MenuItem };
* @since 1.10.0
*/
@event("after-close")

/**
* Fired when a menu item receives focus.
*
* @public
* @param { HTMLElement } ref The currently focused element representing a <code>ui5-menu-item</code>.
* @param { HTMLElement } item The <code>ui5-menu-item</code> represented by the focused element.
* @since 1.23.1
*/
@event<MenuItemFocusEventDetail>("item-focus", {
detail: {
/**
* @public
*/
ref: {
type: HTMLElement,
},
/**
* @public
*/
item: {
type: HTMLElement,
},
},
})

class Menu extends UI5Element {
/**
* Defines the header text of the menu (displayed on mobile).
Expand Down Expand Up @@ -539,7 +570,7 @@ class Menu extends UI5Element {
: (target.getRootNode() as ShadowRoot).host as MenuListItem;
const item = menuListItem.associatedItem as MenuItem;
const mainMenu = this._findMainMenu(item);
mainMenu?.fireEvent("item-focus", { ref: menuListItem, item });
mainMenu?.fireEvent<MenuItemFocusEventDetail>("item-focus", { ref: menuListItem, item });
}

_startOpenTimeout(item: MenuItem, opener: OpenerStandardListItem) {
Expand Down Expand Up @@ -712,4 +743,5 @@ export type {
MenuItemClickEventDetail,
MenuBeforeCloseEventDetail,
MenuBeforeOpenEventDetail,
MenuItemFocusEventDetail,
};

0 comments on commit d5e5944

Please sign in to comment.