fix(ui): fix Select keyboard navigation — first arrow key press now highlights first item#1798
fix(ui): fix Select keyboard navigation — first arrow key press now highlights first item#1798franzheidl wants to merge 2 commits into
Conversation
…ocuses first menu item Only mount portal when menu is open so headless sorts items in the actual rendered dom Signed-off-by: Franz Heidl <f.heidl@sap.com>
|
|
|
DO NOT MERGE – RAW VALUES IN LABELS REGRESSION: Potential regression: pre-selected label shows raw With
One clean fix would be to replace the effect-based registration with a Minor: As of the current Floating UI setup ( |
DO NOT MERGE YET – SEE COMMENT
Problem
When using the keyboard to navigate the menu of a
Select, it takes hitting thearrow-down-key multiple times before the first item was visually focussed. With the hits before items were focussed, too, but without any visual display, which is highly confusing.Root Cause
Dropdown options were always mounted in the DOM, hidden via
display: noneon the Floating UI container. Headless UI's DOM-order sort ran against elements in a hidden subtree on page load, producing an unreliable option order. On first open,goToOptioncouldn't resolve the correct active index and the first few arrow-down presses had no visible effect.Fix
{open && createPortal(...)})so options mount, register, and sort against visible DOM elements
SelectOptionfromas={Fragment}toas="li"so HUI owns theelement and sets
data-activenativelytabIndex={-1}to the floating container to exclude it from sequentialkeyboard focus order
Closes #1781
Test plan
Checklist
PR Manifesto
Review the PR Manifesto for best practises.