Skip to content

Commit

Permalink
fix(ui5-menu): fix focus steal of ui5-wizard in mozilla (#9845)
Browse files Browse the repository at this point in the history
Previously in Mozilla Firefox browser the ui5-menu was 'stealing' the focus of the ui5-wizard resulting in scroll back through the steps.
The problem occured when the ui5-wizard contained a menu, with or without ui5-menu-item, and sub-menus. The reason was due to some timing issue, when executing the _createSubMenu() --then--> _openItemSubMenu() methods in the ui5-menu.
  • Loading branch information
hinzzx authored Oct 9, 2024
1 parent 90e1056 commit c0c90b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 7 additions & 5 deletions packages/main/src/Menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@
</ui5-busy-indicator>
{{/if}}
</div>
</ui5-responsive-popover>

<div
class="ui5-menu-submenus"
>
</div>
{{#if menuHasSubMenus}}
<div
class="ui5-menu-submenus"
>
</div>
{{/if}}
</ui5-responsive-popover>
12 changes: 8 additions & 4 deletions packages/main/src/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ class Menu extends UI5Element {
Menu.i18nBundle = await getI18nBundle("@ui5/webcomponents");
}

get menuHasSubMenus() {
return !!this.items.filter(item => item.hasSubmenu).length;
}

get itemsWithChildren() {
return !!this._currentItems.filter(item => item.item.items.length).length;
}
Expand Down Expand Up @@ -513,12 +517,12 @@ class Menu extends UI5Element {
return fragment;
}

_openItemSubMenu(item: MenuItem, opener: HTMLElement) {
async _openItemSubMenu(item: MenuItem, opener: HTMLElement) {
const mainMenu = this._findMainMenu(item);
mainMenu?.fireEvent<MenuBeforeOpenEventDetail>("before-open", {
item,
}, false, false);
item._subMenu!.showAt(opener);
await item._subMenu!.showAt(opener);
item._preventSubMenuClose = true;
this._openedSubMenuItem = item;
this._subMenuOpenerId = opener.id;
Expand Down Expand Up @@ -553,7 +557,7 @@ class Menu extends UI5Element {
}
}

_prepareSubMenu(item: MenuItem, opener: HTMLElement) {
async _prepareSubMenu(item: MenuItem, opener: HTMLElement) {
const menuItem = item.parentElement ? item : (opener as OpenerStandardListItem).associatedItem;
const parentMenuItem = this._getParentMenuItem(menuItem);

Expand All @@ -564,7 +568,7 @@ class Menu extends UI5Element {
if (menuItem && menuItem.hasSubmenu) {
// create new sub-menu
this._createSubMenu(menuItem, opener);
this._openItemSubMenu(menuItem, opener);
await this._openItemSubMenu(menuItem, opener);
}
if (parentMenuItem) {
parentMenuItem._preventSubMenuClose = true;
Expand Down

0 comments on commit c0c90b2

Please sign in to comment.