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
Make value and defaultValue valid in number and slider fields #5543
Conversation
Build successful! 🎉 |
Build successful! 🎉 |
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.
Should we add a story that connects a NumberField and Slider with the Slider bound to a min/max range and the NumberField allows any number so we can give it values outside the range? RAC Slider docs have an example that does this so we are probably fine.
${'defaultValue maxValue step'} | ${{defaultValue: 20, maxValue: 10, step: 3}} | ${'9'} | ||
${'value minValue'} | ${{value: 20, minValue: 50}} | ${'50'} | ||
${'value maxValue'} | ${{value: 20, maxValue: 10}} | ${'10'} | ||
${'value minValue step'} | ${{value: 20, minValue: 50, step: 3}} | ${'50'} |
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've forgotten why this doesn't clamp to 51. Is it that the step interval start at zero or min?
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.
steps start at the minValue
If RAC has it, we're fine, also we have tests for this now |
if (!isNaN(value)) { | ||
if (!isNaN(step)) { | ||
value = snapValueToStep(value, minValue, maxValue, step); | ||
} else { | ||
value = clamp(value, minValue, maxValue); | ||
} | ||
} |
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.
so this is a departure from native behavior where the initial value provided to the input is respected even if it doesn't match the step but I saw in the spec where it recommends this new behavior so I'm fine with this, feels better anyways
Build successful! 🎉 |
Build successful! 🎉 |
Build successful! 🎉 |
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'any' } |
Closes #4978
Closes #5556
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: