Skip to content

[number field] Fix hidden input focus on submit#3581

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:fix/number-field-validity-focus
Dec 28, 2025
Merged

[number field] Fix hidden input focus on submit#3581
atomiks merged 3 commits into
mui:masterfrom
atomiks:fix/number-field-validity-focus

Conversation

@atomiks

@atomiks atomiks commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Fixes #3574

The main problem in the issue is that stepMismatch was sometimes occurring, and the hidden <input type="number"> was being focused. This emitted an aria-hidden warning and appeared to "block submission" but the real issue is that the submission was (correctly) blocked from stepMismatch, just that focus wasn't being relocated to the right input.

Native <input type="number"> supports step="any" to turn off step validation (while internal controls still assume step={1}), which I have added here for parity. If users want a custom step without step validation, this would require another prop, which can likely wait until an issue is created.

Screenshot 2025-12-28 at 5 44 10 pm

Related

@atomiks atomiks added component: number field Changes related to the number field component. type: bug It doesn't behave as expected. labels Dec 19, 2025
@pkg-pr-new

pkg-pr-new Bot commented Dec 19, 2025

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

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

commit: 95bc36b

@mui-bot

mui-bot commented Dec 19, 2025

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+60B(+0.01%) 🔺+18B(+0.01%)

Details of bundle changes


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

@netlify

netlify Bot commented Dec 19, 2025

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 95bc36b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6950d17eda2e5a0008ee4873
😎 Deploy Preview https://deploy-preview-3581--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 force-pushed the fix/number-field-validity-focus branch from fc7b422 to 333c07f Compare December 19, 2025 06:47
@atomiks atomiks marked this pull request as ready for review December 19, 2025 06:50
@atomiks atomiks force-pushed the fix/number-field-validity-focus branch from 333c07f to 8c6a723 Compare December 23, 2025 10:19

@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.

Logic looks good, let's just update the props description before merging.

Comment thread packages/react/src/number-field/root/NumberFieldRoot.tsx
@atomiks atomiks force-pushed the fix/number-field-validity-focus branch 3 times, most recently from 36c1e91 to ea9b8a3 Compare December 28, 2025 06:14
@atomiks atomiks force-pushed the fix/number-field-validity-focus branch 3 times, most recently from ea954ce to 4160025 Compare December 28, 2025 06:39
@atomiks atomiks force-pushed the fix/number-field-validity-focus branch from 4160025 to 95bc36b Compare December 28, 2025 06:43
@atomiks atomiks merged commit a9d4a8c into mui:master Dec 28, 2025
23 checks passed
@atomiks atomiks deleted the fix/number-field-validity-focus branch December 28, 2025 06:46
atomiks added a commit to atomiks/base-ui that referenced this pull request Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: number field Changes related to the number field component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[number field] Input with aria-hidden focus prevents form submission

3 participants