Skip to content

[form controls] Fix visually hidden input styles#3606

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:fix/visually-hidden-inputs
Dec 24, 2025
Merged

[form controls] Fix visually hidden input styles#3606
atomiks merged 1 commit into
mui:masterfrom
atomiks:fix/visually-hidden-inputs

Conversation

@atomiks

@atomiks atomiks commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

The visuallyHidden util 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:

  • NumberField
  • Radio
  • Checkbox
  • Switch
  • Select
  • Combobox

Slider already handled this correctly


The main issue when not adding top/left is stray overflow (since the visually hidden input takes up layout size) however this should not be a concern for form inputs specifically

@atomiks atomiks added type: bug It doesn't behave as expected. scope: all components Widespread work has an impact on almost all components. labels Dec 24, 2025
@pkg-pr-new

pkg-pr-new Bot commented Dec 24, 2025

Copy link
Copy Markdown
  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@3606
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3606
    

commit: f19a024

@mui-bot

mui-bot commented Dec 24, 2025

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react ▼-13B(0.00%) 🔺+14B(+0.01%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Dec 24, 2025

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f19a024
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/694b71121621940008f54a45
😎 Deploy Preview https://deploy-preview-3606--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks marked this pull request as ready for review December 24, 2025 05:31

@mnajdova mnajdova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'> = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch for removing the useMemo 👍

@atomiks

atomiks commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

@mnajdova ah it's because NumberField adds the required form validation prop on the visible input <NumberField.Input> as well. But, min/max/step validation popups wouldn't point correctly, since the visible input isn't type="number" and the validation props are only on the hidden input in that case.

Screenshot 2025-12-24 at 8 17 53 pm

@mnajdova

Copy link
Copy Markdown
Member

@mnajdova ah it's because NumberField adds the required form validation prop on the visible input <NumberField.Input> as well. But, min/max/step validation popups wouldn't point correctly, since the visible input isn't type="number" and the validation props are only on the hidden input in that case.

Ah ok, makes sense 👌

@atomiks atomiks merged commit 6fb3bc2 into mui:master Dec 24, 2025
24 checks passed
@atomiks atomiks deleted the fix/visually-hidden-inputs branch December 24, 2025 09:25
atomiks added a commit to atomiks/base-ui that referenced this pull request Dec 28, 2025
@LukasTy LukasTy mentioned this pull request Jan 14, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: all components Widespread work has an impact on almost all components. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants