Skip to content

feat: add isValueSnappingDisabled to NumberField#9679

Open
will-stone wants to merge 3 commits intoadobe:mainfrom
will-stone:add-value-snapping-disabled-to-number-field
Open

feat: add isValueSnappingDisabled to NumberField#9679
will-stone wants to merge 3 commits intoadobe:mainfrom
will-stone:add-value-snapping-disabled-to-number-field

Conversation

@will-stone
Copy link

@will-stone will-stone commented Feb 18, 2026

As discussed here: #8776

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

  1. Open the Step3WithMin2Max21ValueSnappingDisabled story.
  2. Enter a value that's either under min, over max, or a wrong step.
  3. Blur the input.
  4. Notice the onChange callback fires with the same value you entered, and the input does not auto-snap to a valid number.

🧢 Your Project:

This will be used in an e-commerce situation where the NumberField is used for product quantity. Snapping is dangerous, for us, because a customer may not know that the number has been auto-healed, causing them to order less or more of what they need. I work for RS Group, and RAC powers our component library: ion. The component in question isn't live yet, but the RAC implementation is to replace our QuantityStepper component.

@will-stone
Copy link
Author

Happy to have a stab at the docs but I'd like to please know if this is something you'd consider adding first 🙏 😅

@LFDanLu
Copy link
Member

LFDanLu commented Feb 20, 2026

@will-stone interesting, this went a bit of a different route than I was expecting but I suppose native number type input fields do behave the same way. @snowystinger Any opinions here? Do you remember any reasons we didn't go this route in the first place?

@will-stone
Copy link
Author

Hi 👋 🙂 Anything I can do to advance this? If you're happy with the name then I can have a crack at the docs.

@LFDanLu
Copy link
Member

LFDanLu commented Mar 10, 2026

@will-stone sorry about the delay, I'll take a look soon. I hadn't realized the team had already discussed this a while back haha, I'll take a look at overall behavior soon. Definitely feel free to take a crack at the docs, the team can help out with those if behavior needs to be refactored/naming gets changed/etc

/**
* Disables value snapping when user finishes editing the value (e.g. on blur).
*/
isValueSnappingDisabled?: boolean
Copy link
Member

@snowystinger snowystinger Mar 10, 2026

Choose a reason for hiding this comment

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

such a long prop name, how would we feel instead about, question to the team
isSnapDisabled

Copy link
Member

Choose a reason for hiding this comment

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

I think that shorter name is fine

Copy link
Member

Choose a reason for hiding this comment

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

perhaps interactOutside behavior related? like RangeCalendar? and DatePicker?
See #8899 (review) as well

expect(onChangeSpy).toHaveBeenCalledWith(5);
expect(textField).toHaveAttribute('value', '5');

expect(container).not.toHaveAttribute('aria-invalid');
Copy link
Member

Choose a reason for hiding this comment

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

maybe in the v3 spectrum component this should be false, but if we write the same test in the react aria component, does it have the invalid attribute? seems like it should

Copy link
Member

Choose a reason for hiding this comment

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

perhaps out of scope for this PR's change, but seeing as setting this snapping option would allow a user to enter a value beyond the upper limit, should we also allow users to enter invalid negative numbers? I'm not sure if there is a realistic use case, but that would also bring us closer to native behavior.

Copy link
Member

@snowystinger snowystinger Mar 14, 2026

Choose a reason for hiding this comment

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

This one is stopped before the user can even see the negative sign reflected in the input, so shouldn't be the same problem. I think we leave it as is for now.

/**
* Disables value snapping when user finishes editing the value (e.g. on blur).
*/
isValueSnappingDisabled?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

I think that shorter name is fine

@snowystinger snowystinger marked this pull request as ready for review March 14, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants