Skip to content

Update selector focus styling and behaviour - #38

Merged
microbit-matt-hillsdon merged 7 commits into
mainfrom
select-fix
Aug 4, 2026
Merged

Update selector focus styling and behaviour#38
microbit-matt-hillsdon merged 7 commits into
mainfrom
select-fix

Conversation

@microbit-grace

@microbit-grace microbit-grace commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #35, #39

  • Fix styling so that using a mouse does not trigger focus ring by removing [data-focused] styling for Selector. As documented in RAC Select component, using a mouse or keyboard triggers data-focused on the selector.
  • Update combo selector focus styling to match input recipe. I didn't copy the hover effect as the TextField in https://react-aria.adobe.com/TextField doesn't have it.

@microbit-grace microbit-grace changed the title Remove &[data-focused] style Removes [data-focused] styling for Selector Aug 3, 2026
@microbit-grace
microbit-grace marked this pull request as draft August 3, 2026 16:18
@microbit-grace

Copy link
Copy Markdown
Contributor Author

Going to fix #39 here as well

so that when you mouse/keyboard focus on the selector, it changes border color without focus shadow. Also, remove borderColor hover effect.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploying ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: ea3813d
Status: ✅  Deploy successful!
Preview URL: https://899e2138.ui-2wg.pages.dev
Branch Preview URL: https://select-fix.ui-2wg.pages.dev

View logs

@microbit-grace
microbit-grace marked this pull request as ready for review August 4, 2026 10:42
@microbit-grace microbit-grace changed the title Removes [data-focused] styling for Selector Update selector focus styling and behaviour Aug 4, 2026
Three state rules on the shared trigger slot, in the order the input
recipe documents: hover, then invalid, then focus, so red beats a hover
tint and the focus ring beats red.

Focus keyed off `data-focused` never survived an open ComboBox list.
react-aria dispatches a synthetic blur at the input when virtual focus
moves to an option, so RAC clears the attribute while real focus has not
moved. `menuTrigger="focus"` with a selection hits this on the first tab,
which is why the icon story in #39 still had no ring; every ComboBox also
lost it on arrowing into the list. Native `:focus` cannot be taken away
this way.

Invalid never matched anything. RAC marks the field root, and in a
ComboBox the input, but never the trigger: its Button has no validity
state and our ComboBox control is a plain div. The rule now comes down
from the parent, with the border plus 1px ring the input recipe uses
rather than the border alone. Scoped to a direct child so an app's own
invalid form wrapper cannot paint every control inside it red.

Hover returns. The input recipe carries it, and both NativeSelect and
TextField's input render that recipe, so dropping it from the trigger
left a Select the only control in a form that did not tint.

The tests take these selectors from the recipe rather than restating
them, so keying off an attribute RAC does not set fails there rather
than in a browser. The Invalid story grows a form whose required Select
and ComboBox go red on submit; its docstring records that red is the
only signal a Select can give, which is #41.
react-aria keeps a ComboBox's toggle button out of the tab order, since
the input owns the keyboard in the ARIA combobox pattern, and a pointer
sets the focus modality to not-visible. So `data-focus-visible` on the
indicator slot only ever arrived through a programmatic focus, and the
4px ring it asked for was the one treatment in the component that did not
match the control beside it. The whole control shows focus instead.
@microbit-matt-hillsdon
microbit-matt-hillsdon merged commit 2310183 into main Aug 4, 2026
2 checks passed
@microbit-matt-hillsdon
microbit-matt-hillsdon deleted the select-fix branch August 4, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-native select has visible focus indicator after mouse selection

2 participants