-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix difficult to use RangeControl when minimum value specified #25131
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 difficult to use RangeControl when minimum value specified #25131
Conversation
3ea7cca to
4fe5a1f
Compare
4fe5a1f to
a18fea4
Compare
a18fea4 to
f41e4ae
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.
Thanks for working on this!
The change looks good to me, very thorough! In testing it solves the issue and I couldn't spot any unwanted side-effects.
Applying the curly braces mentioned in the comment before merging would be great. (actually I went ahead and did this, as it was such a small thing).
Also pinging @ItsJonQ to make you aware of the change, but I don't see any reason not to push forwards with this right now.
|
Oh, dang! Here I've been composing a long reply with some issues I've found and I was too slow 🐢 . Looks like this PR should implement some affordance toward backward compatibility with the old behavior of To detail the issues in blocks due to lack of backward compatibility they present in Image, Latest Comments and Spacer. To be clear these are not introduced by this PR just not fixed by it. For Image, the issue can be reproduced by clearing the input in the range control used to adjust zoom while cropping. It will crash the block 🙀 For Latest Comments, the issue can be reproduced by entering an out-of-range value in the range control input for "Number of comments". This one is not so bad, the block warns: "Error loading block: Invalid parameter(s): attributes" but it is easily recovered. For Spacer, there are three ways it can misbehave. The first can be reproduced by clearing the input in the range control used to adjust the height. If you don't have your console open you could miss it. React warns that: "Received NaN for the As for the issue with |
|
@stokesman No worries. I've reverted the commit in #25601, lets work to fix those other issues and then introduce this change. |
|
Thanks @talldan, this should handle it. I'm calling it a day and haven't tested it thoroughly but I'll do so tomorrow. |

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
onChangeis called even when its value is out of range. Actually, this PR doesn't introduce the change. It must have come along with the changes that regressed [ Latest Posts ] Max. number of words control doesn't react to keyboard input #21549. Mentioning it here for thoroughness since this PR doesn't revert the behavior.Checklist: