Skip to content

[number field] Keep native selection behavior when focusing the input - #5578

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:claude/native-input-behavior-bbe5a1
Aug 27, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:claude/native-input-behavior-bbe5a1

Conversation

@atomiks

@atomiks atomiks commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #5576

Tabbing into the input natively selects the whole value, but a first-focus setSelectionRange override collapsed that selection to the end, so the first tab-in behaved differently from every later one. In Firefox the same override also moved the caret to the end on the first click, ignoring the click position.

Changes

  • Removed the first-focus selection override from the input. Keyboard and pointer focus now keep the browser's native selection.
  • Moved the caret-at-end placement into a shared focusInput() helper used by the programmatic focus paths (stepper buttons, scrub area, hidden input focus redirect), where it is still needed: programmatic focus places the caret at the start in Chrome/Firefox and selects the whole value in WebKit. The helper sets the selection after focus() returns because WebKit applies its own selection after dispatching the focus event, which overrides any range set inside a focus handler.

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

pkg-pr-new Bot commented Aug 27, 2026

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

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

commit: 6e6c2f4

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Bundle size

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

Details of bundle changes

Performance

Total duration: 858.28 ms -28.13 ms(-3.2%) | Renders: 76 (+0) | Paint: 1,360.14 ms -45.75 ms(-3.3%)

No significant changes — details


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

@netlify

netlify Bot commented Aug 27, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 6e6c2f4
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a8fc9e3f3de6a000860d057
😎 Deploy Preview https://deploy-preview-5578--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@atomiks
atomiks marked this pull request as ready for review August 27, 2026 05:41
@atomiks
atomiks merged commit 7cfbf55 into mui:master Aug 27, 2026
10 checks passed
@atomiks
atomiks deleted the claude/native-input-behavior-bbe5a1 branch August 27, 2026 05:43
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] inconsistent selection when tabbing into the input (first focus vs later ones)

1 participant