-
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 UnitControl
resets unit when value is cleared
#39531
Conversation
e383f1b
to
5415096
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.
Apologies in case this PR wasn't ready for review, but I thought I'd give it a look anyway 😅
I tested the changes in this PR and they work as per instructions 🚀
Before
unit-control-unit-reset-before.mp4
After
unit-control-unit-reset-after.mp4
It'd be great if we could add a unit test to avoid future regressions — what do you think?
Finally, we'll also need to add an entry to the CHANGELOG for this bug fix.
Thanks for testing this out! I do think it was mostly ready for review but indeed I think a unit test and changelog entry are warranted. I'll get to that but later in the day tomorrow at earliest. I've got to prioritize some other stuff for now. |
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 so much for picking this one up @stokesman! This is testing nicely for me so far, too, great that it's a straightforward fix.
+1 Good to add in unit tests, though 🙂
5415096
to
917344b
Compare
Size Change: +5 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
917344b
to
eebe7a8
Compare
eebe7a8
to
ba85ce3
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.
LGTM 🚀 Thank you @stokesman !
- Tests well in storybook and in the editor
- New unit tests pass (they fail as expected when I remove the fix included in this PR)
I pushed a quick commit to solve a CHANGELOG conflict.
We can merge this PR as soon as CI checks pass
Thanks for testing and reviewing @ciampo and @andrewserong! |
* Avoid setting unit from effect hook if parsed to `undefined` * Add unit test * Add changelog entry * Remove duplicated `Bug Fix` section in the CHANGELOG Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
What?
Prevents reset of the unit when the quantity input is cleared in
UnitControl
.Why?
I believe this will mostly resolve #38872. Some instances of the issue may be due to components still passing the deprecated
unit
prop toUnitControl
but those are being fixed in separate PRs. For instance, I noticed that the border radius control was not fixed by this PR but if the change from #39549 is applied on top of this then it is fixed.How?
Does not set the unit from parsed value prop if the unit returned by the parse is
undefined
.Testing Instructions
Try the
UnitControl
component in storybook or border width controls in the block editor.