-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: range control direct entry in input field #25609
Fix: range control direct entry in input field #25609
Conversation
9edb601
to
fb367a5
Compare
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.
@stokesman Wowow! Thank you so much for improving this. I had tried to improve the value
sync (between uncontrolled and controlled) in the latest iterations of these controls (the base InputControl
).
I think you cracked it by leveraging the blur
event as the "trigger" mechanism to consolidate - very clever 👏 !!!
I left a comment in regards to the type
for NumberControl
within RangeControl
. Not a huge thing at all.
Tested all of the affected controls locally.
Tested mouse + keyboard interactions as well as controlled and uncontrolled states.
It's working as expected!
Approved from me!
P.S. A part of me is still unsure about using the blur
approach, but that's 100% due to my personal unfamiliarity with the technique - rather than something being wrong <3
Additionally: - Test updates - A formatting fix.
fb367a5
to
fe0563c
Compare
- on blur use handleOnReset if allowRest is true - call onChange with a clamped value if new value is out-of-range - update test to use invalid value instead of out-of-range value - aside: remove an extraneous prop from number input
fe0563c
to
e211983
Compare
I've pushed some updates because I found an issue with the value reset on blur happening when it shouldn't. Along with that, I realized I had some extraneous logic in there and what was probably overeager avoidance of @ItsJonQ, I'm glad you were added to review.
I very much relate to that! I've gotten to be fairly confident it's good for this use case. I was also unsure about putting it in Along those lines, I've come to suspect the value state management for |
@stokesman I've tested it on my side, and it works as expected :). The changes look good to me 👍 . If something unexpected just arise from this update, we can refine the implementation then! (or revert if we need and revisit how state syncing should be handled, haha) Thanks again! |
💯 |
The impetus is to fix #24460 which is a regression. The solution in this PR is simple and includes a test to prevent regressions but did require minor changes to quite a few tests. Also, though tangential to the issue, there is the removal of some extraneous code.
The core change is to InputControl, revising logic for value state updates and propagation. It no longer updates the internal value state from props while the input has focus. The change ensures that entry will be unimpeded by the validation logic of consuming components (such as RangeControl).
A new test is added for RangeControl specifying the allowance of invalid values in the input element until the loss of focus. It was confirmed to fail before the rest of the changes were added and so guards against future regressions.
Ancillary changes are the removal of RangeControl's wrapping of NumberControl and test updates to work with the new InputControl implementation detail.
How has this been tested?
Types of changes
Checklist: