diff --git a/src/components/sbb-menu/sbb-menu.tsx b/src/components/sbb-menu/sbb-menu.tsx index 81534e1845..30725bd69c 100644 --- a/src/components/sbb-menu/sbb-menu.tsx +++ b/src/components/sbb-menu/sbb-menu.tsx @@ -344,12 +344,17 @@ export class SbbMenu implements ComponentInterface { // Set focus on the first focusable element. private _setDialogFocus(): void { - if (sbbInputModalityDetector.mostRecentModality === 'keyboard') { - getFirstFocusableElement( + if ( + sbbInputModalityDetector.mostRecentModality === 'keyboard' || + sbbInputModalityDetector.mostRecentModality === 'touch' + ) { + const firstFocusable = getFirstFocusableElement( Array.from(this._element.children).filter( (e): e is HTMLElement => e instanceof window.HTMLElement, ), - )?.focus(); + ); + setModalityOnNextFocus(firstFocusable); + firstFocusable?.focus(); } else { // Focusing sbb-menu__content in order to provide a consistent behavior in Safari where else // the focus-visible styles would be incorrectly applied