Skip to content

Commit

Permalink
fix(sbb-menu): menu action focus on mobile (#2103)
Browse files Browse the repository at this point in the history
  • Loading branch information
dauriamarco authored Oct 23, 2023
1 parent 8153ad3 commit 9827fa1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/sbb-menu/sbb-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9827fa1

Please sign in to comment.