[form controls] Fix visually hidden input styles#3606
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
mnajdova
left a comment
There was a problem hiding this comment.
Example of fixed component (RadioGroup): https://stackblitz.com/edit/nrb7shnu?file=src%2FApp.tsx
Broken on master: https://stackblitz.com/edit/ub6e7bxf?file=src%2FApp.tsx
I noticed that the number field was already working, I am not sure why, e.g. check: https://stackblitz.com/edit/snm2yjeu?file=package.json, but in general using the new visually hidden styles for inputs makes sense.
| if (event.nativeEvent.defaultPrevented) { | ||
| return; | ||
| } | ||
| const inputProps: React.ComponentPropsWithRef<'input'> = { |
There was a problem hiding this comment.
Good catch for removing the useMemo 👍
|
@mnajdova ah it's because
|
Ah ok, makes sense 👌 |

The
visuallyHiddenutil isn't suitable for hidden inputs in form controls because native validation popups won't point to them (since the hidden input is at the top-left of the screen currently). They instead should be positioned where the control is.Affects:
NumberFieldRadioCheckboxSwitchSelectComboboxSlideralready handled this correctlyThe main issue when not adding
top/leftis stray overflow (since the visually hidden input takes up layout size) however this should not be a concern for form inputs specifically