Skip to content

[Slider] Commit keyboard inputs on key release instead of every step - #5604

Open
azeng4499 wants to merge 1 commit into
mui:masterfrom
azeng4499:feature/slider-input-commit-frequency
Open

[Slider] Commit keyboard inputs on key release instead of every step#5604
azeng4499 wants to merge 1 commit into
mui:masterfrom
azeng4499:feature/slider-input-commit-frequency

Conversation

@azeng4499

@azeng4499 azeng4499 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

A slider can be adjusted two ways:

  • Dragging fires onValueChange on every pointer move, but onValueCommitted only once the pointer is released.
  • Keyboard fires onValueCommitted on every step, causing each step's value to be continuous committed until key is released.

The keyboard input values should only be committed once the user lets go, the same way dragging works. Committing on every keyboard step causes unnecessary commit callbacks, potentially slowing down the UI on expensive operations.

Fix

Defer the keyboard commit until the key is released:

  • SliderRoothandleInputChange now stashes keyboard values in a pendingKeyboardValueRef instead of committing immediately. A new commitKeyboardValue callback fires onValueCommitted once with the pending value and clears the ref.
  • SliderThumb — added an onKeyUp handler on the input that commits the pending value when a stepping key is released, plus a fallback in onBlur for the rare case where the keyup never reaches the input.
  • SliderRootContext — exposes commitKeyboardValue so the thumb calls logic owned by the root.

Tests

Added tests to SliderRoot.test.tsx to ensure keyboard input behavior is adhered.

Closes #5595

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown

commit: ba90167

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 31, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+212B(+0.05%) 🔺+80B(+0.05%)

Details of bundle changes

Performance

Total duration: 1,008.79 ms -65.87 ms(-6.1%) | Renders: 76 (+0) | Paint: 1,631.18 ms -117.51 ms(-6.7%)

No significant changes — details


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

@azeng4499

Copy link
Copy Markdown
Contributor Author

This could be breaking depending on how y'all define "breaking".

@netlify

netlify Bot commented Aug 31, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ba90167
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a96092d4cd10f0009edc060
😎 Deploy Preview https://deploy-preview-5604--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.

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.

[Slider] Keyboard input commits on every step rather than on key up when held

1 participant