Skip to content

[number field] Stop repeat change at bounds - #3915

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:fix/number-field-hold-max
Feb 4, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
atomiks:fix/number-field-hold-max

Conversation

@atomiks

@atomiks atomiks commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #3887

@atomiks atomiks added component: number field Changes related to the number field component. type: bug It doesn't behave as expected. labels Feb 1, 2026
@atomiks atomiks changed the title [number-field] Stop repeat change at bounds [number field] Stop repeat change at bounds Feb 1, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 1, 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@3915
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3915
    

commit: ab9ca05

@mui-bot

mui-bot commented Feb 1, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+152B(+0.04%) 🔺+65B(+0.05%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit ab9ca05
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6982f58ce3b1ee00084bdf17
😎 Deploy Preview https://deploy-preview-3915--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 February 1, 2026 20:21
@greptile-apps

greptile-apps Bot commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Modified the number field's auto-increment and auto-decrement behavior to stop repeating when min/max bounds are reached.

Key changes:

  • Changed setValue and incrementValue functions to return a boolean indicating whether the value actually changed
  • Modified shouldFireChange logic to distinguish between input-driven changes and programmatic changes (increment/decrement/wheel/scrub)
  • For programmatic changes, only fire change events when the validated value actually differs from the current value
  • Updated startAutoChange to check the return value from tick() and stop the auto-repeat interval when bounds are reached
  • Added comprehensive tests verifying that onValueChange stops being called once min/max is reached during auto-increment/decrement

Impact:
Previously, when holding down the increment or decrement button, onValueChange would continue firing repeatedly even after reaching the min/max bounds. Now it correctly stops firing once the bound is reached, improving performance and preventing unnecessary re-renders.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-designed and thoroughly tested. The logic correctly distinguishes between input-driven and programmatic changes, ensuring the auto-repeat stops only for increment/decrement/wheel/scrub operations at bounds while preserving existing behavior for user input. The added tests verify the fix works as expected.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/number-field/root/NumberFieldRoot.tsx Changed setValue and incrementValue to return boolean indicating if change occurred, used to stop auto-increment/decrement at bounds
packages/react/src/number-field/increment/NumberFieldIncrement.test.tsx Added test verifying onValueChange stops being called once max is reached during auto-increment
packages/react/src/number-field/decrement/NumberFieldDecrement.test.tsx Added test verifying onValueChange stops being called once min is reached during auto-decrement

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

I thought there was a reason for repeating it 🤔

@atomiks
atomiks merged commit 25e2655 into mui:master Feb 4, 2026
7 checks passed
@atomiks
atomiks deleted the fix/number-field-hold-max branch February 4, 2026 07:34
@coderabbitai coderabbitai Bot mentioned this pull request Aug 12, 2026
5 tasks done
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] holding down on NumberField.Increment or NumberField.Decrement retriggers onValueChange after reaching the max / min

3 participants