-
Notifications
You must be signed in to change notification settings - Fork 21
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
React/DP-12921: Prevents min/max from being past on InputNumber and InputCurrency. #503
Conversation
…yflower into react/DP-12734--currency-with-focus
Since min/max only limits the inputs based on submission, and we are submitting values using onBlur. I think we should do a check in onBlur so that it's preventing out-of-bound values, both in inputCurrency and inputNumber. I would suggest in handleChange/handleBlur we do a check and if input exceeds max, value will be set to max and if it exceeds min, it will be set to min. Let me know if that doesn't make sense. |
For InputCurrency formatting, is there a way to keep track on the actual number value with user interaction and have the display be a layer on top of that. e.g. when user backspace it will remove digits and will prevent the displayed User should not be able to modify the displayed See these examples: |
@@ -14,8 +14,16 @@ storiesOf('atoms/forms', module) | |||
'InputNumber', (() => { | |||
const inputTextOptionsWithKnobs = Object.assign(...Object.entries(InputNumberOptions).map(([k, v]) => ( | |||
{ [k]: v() }))); | |||
const storyProps = { | |||
style: (inputTextOptionsWithKnobs.inline) ? { width: '400px' } : { width: '200px' } |
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.
Is this only for testing purposes? do you want to you remove it to fix the visual regression?
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.
This is only for the story, but I should update the backstop image.
…yflower into react/DP-12921--input-min-max
…yflower into react/DP-12921--input-min-max
const displayErrorMessage = (val, min, max, isRequired) => { | ||
if (isRequired && String(val).length === 0) { | ||
const displayErrorMessage = (val) => { | ||
const { min, max, isRequired } = props; |
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.
const { min, max, isRequired } = props; | |
const { min, max, required } = props; |
if (isRequired && String(val).length === 0) { | ||
const displayErrorMessage = (val) => { | ||
const { min, max, isRequired } = props; | ||
if (isRequired && is.empty(val)) { |
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.
if (isRequired && is.empty(val)) { | |
if (required && is.empty(val)) { |
Co-Authored-By: smurrayatwork <smurrayatwork@gmail.com>
Co-Authored-By: smurrayatwork <smurrayatwork@gmail.com>
…yflower into react/DP-12921--input-min-max
}); | ||
} | ||
}, | ||
onFocus: (e) => { |
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.
Can you put this unformatting logic back in this pr?
changelogs/DP-12921.md
Outdated
Changed | ||
- (React) [InputNumber] DP-12921: Limits the component from changing value between the min and max passed. | ||
- (React) [InputCurrency] DP-12921: Limits the component from changing value between the min and max passed. | ||
- (React) [InputCurrency] DP-12734: Prevents changing currency to numbers from strings on focus. |
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.
can you update the changelog here - removing this per comment below.
Description
Related Issue / Ticket
Steps to Test