Reproduction of the bug in a codepen:
https://codepen.io/anon/pen/ePNjmo
Bug Report
- Package version(s): 6.75.0
- Browser and OS versions: Chrome, Mac OS
Priorities and help requested:
Are you willing to submit a PR to fix? Yes
Requested priority: Normal
Describe the issue:
Used FocusTrapZone, few elements inside have tabindex="0", others tabindex="-1", also data-is-focusable="true". I used data-is-focusable="true", as I have FocusZone inside FocusZoneTrap
When tabbing through Focus Trap Zone, lastTabbableElement is defined incorrectly what leads to tab out from trap.
Please, look at the bug reproduction here https://codepen.io/anon/pen/ePNjmo
Actual behavior:
It is possible to tab out from focus trap.
Expected behavior:
It is not possible to tab out from focus trap.
Fix
After investigating code, found out that getPreviousElement does not pass tabbable to all places, see https://github.com/OfficeDev/office-ui-fabric-react/blob/1b9405b3b64839975e16ee1fad04d7868d9e3b99/packages/utilities/src/focus.ts#L205
After trying to pass tabbable to that place, it fixed my issue.
Reproduction of the bug in a codepen:
https://codepen.io/anon/pen/ePNjmo
Bug Report
Priorities and help requested:
Are you willing to submit a PR to fix? Yes
Requested priority: Normal
Describe the issue:
Used FocusTrapZone, few elements inside have
tabindex="0", otherstabindex="-1", alsodata-is-focusable="true". I useddata-is-focusable="true", as I have FocusZone inside FocusZoneTrapWhen tabbing through Focus Trap Zone,
lastTabbableElementis defined incorrectly what leads to tab out from trap.Please, look at the bug reproduction here https://codepen.io/anon/pen/ePNjmo
Actual behavior:
It is possible to tab out from focus trap.
Expected behavior:
It is not possible to tab out from focus trap.
Fix
After investigating code, found out that
getPreviousElementdoes not passtabbableto all places, see https://github.com/OfficeDev/office-ui-fabric-react/blob/1b9405b3b64839975e16ee1fad04d7868d9e3b99/packages/utilities/src/focus.ts#L205After trying to pass
tabbableto that place, it fixed my issue.