-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(NumberInput): Allow empty input for NumberInput with allowEmpty prop (#15985) #16100
fix(NumberInput): Allow empty input for NumberInput with allowEmpty prop (#15985) #16100
Conversation
DCO Assistant Lite bot All contributors have signed the DCO. |
✅ Deploy Preview for v11-carbon-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I have read the DCO document and I hereby sign the DCO. |
recheck |
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.
LGTM 👍 ✅ Thanks for contributing and the detailed explanations! Would updating the helper text to display the minimum or maximum or updating the example to a minimum of -100
help alleviate the original confusion?
Hi @tw15egan, yes, I'd imagine adding the context to the helper text would alleviate some of the confusion. Though, would this be a default? Does this then occur for every param that could throw an error? In this instance, might just be worth updating the helper text in the implementation of the storybook demo first. After which, it could be worth defining better what should be shipped in the design system library vs what should be added in the individual implementation without adding a bunch of cruft or overhead. Is it worth a different issue for planning that feature set? |
@hollyos Yeah, that's a good point, I think updating the storybook is all that's needed. We can track that separately |
@tw15egan currently, the validity checker is only a bool response. There's no context as to the reason for the failure. Without adding a bunch of overhead, may just be worth updating |
Hey @hollyos Thanks for your contribution, this looks good 🔥
|
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.
@hollyos there are also some failing AVT tests, do you mind fixing those? Thank you!
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.
I updated the avt tests to reflect the new min
value in the default story. This prop isn't covered by any unit tests right now, I've opened #16207 to track addressing that so we can merge this.
6236d6e
Closes #15985
Closes #16016
There were multiple issues open for functionality in the NumberInput.
The input did not allow for an empty input, even with
allowEmpty = true
.Number()
automatically assigns0
to an empty string. A ternary was added to capture this instance and allow for the empty string whenallowEmpty = true
. It will still default to 0 whenallowEmpty = false
.The input did not allow for negative input. I tested this in the live demo and Storybook. It works in both instances. This issue was likely due to the
min
value equaling 0. Whenmin
is updated to a negative value, the input allows for negatives.Changelog
Changed
allowEmpty = true
Testing / Reviewing
allowEmpty
true
min
-200
min
value. Should allow the value and not show an error.