From 20834e229a8c17f1c2d0af9edb658578e3245475 Mon Sep 17 00:00:00 2001 From: Adrian Borrmann Date: Mon, 13 Apr 2026 13:05:45 -0600 Subject: [PATCH 1/3] Fix tab key not working in dropdowns in Safari --- .../src/components/css/dropdown.css | 6 ++ .../src/fragments/Dropdown.tsx | 39 ++++++++ .../tests/integration/dropdown/test_a11y.py | 90 +++++++++++++++++++ 3 files changed, 135 insertions(+) diff --git a/components/dash-core-components/src/components/css/dropdown.css b/components/dash-core-components/src/components/css/dropdown.css index 5667b85060..6a74a79df0 100644 --- a/components/dash-core-components/src/components/css/dropdown.css +++ b/components/dash-core-components/src/components/css/dropdown.css @@ -55,6 +55,12 @@ cursor: not-allowed; } +.dash-dropdown-focus-target { + position: absolute; + opacity: 0; + pointer-events: none; +} + .dash-dropdown-value { max-width: 100%; text-align: left; diff --git a/components/dash-core-components/src/fragments/Dropdown.tsx b/components/dash-core-components/src/fragments/Dropdown.tsx index 6a838fb1df..cc3f1f230c 100644 --- a/components/dash-core-components/src/fragments/Dropdown.tsx +++ b/components/dash-core-components/src/fragments/Dropdown.tsx @@ -313,6 +313,7 @@ const Dropdown = (props: DropdownProps) => { const relevantKeys = [ 'ArrowDown', 'ArrowUp', + 'Tab', 'PageDown', 'PageUp', 'Home', @@ -342,6 +343,19 @@ const Dropdown = (props: DropdownProps) => { let nextIndex: number; switch (e.key) { + case 'Tab': { + // Trap Tab inside the popover so Safari (which + // skips non-text inputs) can navigate options. + const next = current + (e.shiftKey ? -1 : 1); + if (next < minIndex) { + nextIndex = maxIndex; + } else if (next > maxIndex) { + nextIndex = minIndex; + } else { + nextIndex = next; + } + break; + } case 'ArrowDown': nextIndex = current < maxIndex ? current + 1 : minIndex; break; @@ -408,12 +422,37 @@ const Dropdown = (props: DropdownProps) => { const popover = ( + {/* Safari skips