Skip to content

Commit d5e5944

Browse files
authored
docs(ui5-menu): make focus event public (#8407)
1 parent 012fc4d commit d5e5944

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

packages/main/src/Menu.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ type MenuItemClickEventDetail = {
5656
type MenuBeforeOpenEventDetail = { item?: MenuItem };
5757
type MenuBeforeCloseEventDetail = { escPressed: boolean };
5858

59+
type MenuItemFocusEventDetail = {
60+
ref: HTMLElement,
61+
item: MenuItem,
62+
};
63+
5964
type OpenerStandardListItem = StandardListItem & { associatedItem: MenuItem };
6065

6166
/**
@@ -184,6 +189,32 @@ type OpenerStandardListItem = StandardListItem & { associatedItem: MenuItem };
184189
* @since 1.10.0
185190
*/
186191
@event("after-close")
192+
193+
/**
194+
* Fired when a menu item receives focus.
195+
*
196+
* @public
197+
* @param { HTMLElement } ref The currently focused element representing a <code>ui5-menu-item</code>.
198+
* @param { HTMLElement } item The <code>ui5-menu-item</code> represented by the focused element.
199+
* @since 1.23.1
200+
*/
201+
@event<MenuItemFocusEventDetail>("item-focus", {
202+
detail: {
203+
/**
204+
* @public
205+
*/
206+
ref: {
207+
type: HTMLElement,
208+
},
209+
/**
210+
* @public
211+
*/
212+
item: {
213+
type: HTMLElement,
214+
},
215+
},
216+
})
217+
187218
class Menu extends UI5Element {
188219
/**
189220
* Defines the header text of the menu (displayed on mobile).
@@ -539,7 +570,7 @@ class Menu extends UI5Element {
539570
: (target.getRootNode() as ShadowRoot).host as MenuListItem;
540571
const item = menuListItem.associatedItem as MenuItem;
541572
const mainMenu = this._findMainMenu(item);
542-
mainMenu?.fireEvent("item-focus", { ref: menuListItem, item });
573+
mainMenu?.fireEvent<MenuItemFocusEventDetail>("item-focus", { ref: menuListItem, item });
543574
}
544575

545576
_startOpenTimeout(item: MenuItem, opener: OpenerStandardListItem) {
@@ -712,4 +743,5 @@ export type {
712743
MenuItemClickEventDetail,
713744
MenuBeforeCloseEventDetail,
714745
MenuBeforeOpenEventDetail,
746+
MenuItemFocusEventDetail,
715747
};

0 commit comments

Comments
 (0)