-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add interactOutsideBehavior to NumberField #9679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,7 +29,15 @@ export interface NumberFieldProps extends InputBase, Validation<number>, Focusab | |||||
| * Formatting options for the value displayed in the number field. | ||||||
| * This also affects what characters are allowed to be typed by the user. | ||||||
| */ | ||||||
| formatOptions?: Intl.NumberFormatOptions | ||||||
| formatOptions?: Intl.NumberFormatOptions, | ||||||
| /** | ||||||
| * Controls the behavior of the number field when the user interacts outside of the field after editing. | ||||||
| * 'clamp' will clamp the value to the min/max values. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Maybe 'snap' would be more correct since it also applies to step values? |
||||||
| * 'none' will not clamp the value and will allow the value to be outside of the min/max values. | ||||||
| * No native validation around min/max. Provide your own validation function via the `validate` prop. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm we should mark the field as invalid if it is outside the min/max, or not on a step. You shouldn't need to re-implement this validation yourself |
||||||
| * @default 'clamp' | ||||||
| */ | ||||||
| interactOutsideBehavior?: 'clamp' | 'none' | ||||||
| } | ||||||
|
|
||||||
| export interface AriaNumberFieldProps extends NumberFieldProps, DOMProps, AriaLabelingProps, TextInputDOMEvents { | ||||||
|
|
||||||
There was a problem hiding this comment.
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