Shopify / dawn

Shopify's first source available reference theme, with Online Store 2.0 features and performance built-in.
Other
2.48k stars 3.33k forks source link

Menu drawer focus not trapped #2496

Open kmeleta opened 1 year ago

kmeleta commented 1 year ago

Describe the current behavior

The focus trap used in the menu drawer breaks in several scenarios and allows focus to escape outside the dialog. It appears to occur when..

https://screenshot.click/05-30-cea10-p4hnd.mp4

Describe the expected behavior

Focus should always be trapped in the drawer and return to the menu toggle when tabbing past the last focusable item.

Version information (Dawn, browsers and operating systems)

Noticed on Dawn 8.0.0

Possible solution

The elements in the localization disclosures are being recognized as the last focusable item in the dialog, rather than the parent element or triggering button.

The account button can also get recognized as the last element even when it is hidden (the issue wouldn't occur on mobile when the account button becomes visible).

kmeleta commented 1 year ago

Related to or possibly a duplicate of https://github.com/Shopify/dawn/issues/360.