Repository navigation
Fix dcc.Dropdown Shift+Tab focus trap on hidden focus-target input - #4207
Open
SalmanBarkat wants to merge 1 commit into
Open
SalmanBarkat wants to merge 1 commit into
SalmanBarkat wants to merge 1 commit into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #4191
Root Cause
\Dropdown\ renders a hidden <input className=dash-dropdown-focus-target aria-hidden=true>\ with \ abIndex={0}\ right before the trigger <button tabIndex={-1}>\ so Safari includes the dropdown in the \Tab\ order.
Previously, \dummyInput.tabIndex = -1\ was only cleared inside the hidden input's own \onFocus\ handler, while the trigger button's \onBlur\ always restored \dummyInput.tabIndex = 0. Whenever focus landed directly on the trigger <button>\ without first passing through the hidden input (for example after clicking the trigger, closing the popover with \Escape, or selecting an option with \closeOnSelect), the hidden input remained at \ abIndex={0}. Pressing \Shift+Tab\ from the trigger <button>\ then moved focus back onto the hidden \�ria-hidden\ input (with
elatedTarget === dropdownContainerRef.current), trapping keyboard focus there.
What Changed
Verification
pm run test:jest\ in \components/dash-core-components: 10 passed test suites, 96 passed tests (93 existing + 3 new tests in \ocusTarget.test.tsx).
px eslint src/fragments/Dropdown.tsx tests/unit/dropdown/focusTarget.test.tsx: 0 errors.
Contributor Checklist
ext\ (feature, new API, breaking change), see Which branch to target