You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue
The focus layer keyboard trap can be broken if the first or last focusable element is hidden and therefore not considered tabbable/focusable by the browser. This is a result of the tree walker filtering elements with a tabindex, but not considering whether those elements may have display: none; or visiblity:hidden; applied.
A real-world scenario where this breaks is a modal with any kind of collapsed menu contained within it, such as a menu in a video player.
Test Case
Here is a working test case of the bug with repro steps: https://vigilant-cacti.surge.sh/.
My fork of this repository contains the source for the repro example.
Proposed Fix
Adding additional checks to the tree walker filter for height and visibility in src/util/wrapFocus.tsx to cover situations where an element has tabindex and is not disabled, but might be un-focusable due to display: none; or visiblity:hidden;.
The text was updated successfully, but these errors were encountered:
voidloaf
changed the title
Focus trap broken when first of last focusable element is hidden
Focus trap broken when first or last focusable element is hidden
Jan 31, 2023
Issue
The focus layer keyboard trap can be broken if the first or last focusable element is hidden and therefore not considered tabbable/focusable by the browser. This is a result of the tree walker filtering elements with a tabindex, but not considering whether those elements may have
display: none;
orvisiblity:hidden;
applied.A real-world scenario where this breaks is a modal with any kind of collapsed menu contained within it, such as a menu in a video player.
Test Case
Here is a working test case of the bug with repro steps: https://vigilant-cacti.surge.sh/.
My fork of this repository contains the source for the repro example.
Proposed Fix
Adding additional checks to the tree walker filter for height and visibility in
src/util/wrapFocus.tsx
to cover situations where an element has tabindex and is not disabled, but might be un-focusable due todisplay: none;
orvisiblity:hidden;
.The text was updated successfully, but these errors were encountered: