Box Control: fix issue with negative values#60984
Conversation
|
Size Change: -86 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Thanks for the quick fix!
I pushed unit tests (5e9785d) to clarify what broke in #60347. It broke the default min value for the input, as well as the ability to pass props through to the input via the inputProps prop. You can also manually check this in the Storybook.
I also noticed that the drag behavior changes were only made on one specific case (unlinked and not split on axis), of which there are two other cases (linked, unlinked and split on axis). This wasn't intentional, right? And since the original intent was to modify behavior for the margin controls in the block editor dimensions panel, not all instances of BoxControl, I believe we should move this dragging logic out of BoxControl as well. We can just as easily pass down those onDrag props via the inputProps prop from the dimensions-panel.js file, like we did with the min value.
The problem with passing onDrag from dimensions-panel.js is that BoxControl is changing all sides, not just one. How would onDrag look like then? how do we know which of the sides is actually being changed? |
I gave it a try here, but I'm unsure if it's okay to do like that since we are changing the min for all sides? I suppose since we recheck on onDragStart, it should be fine |
mirka
left a comment
There was a problem hiding this comment.
This is good to go from the wp-components perspective, as the custom logic is all moved out 👍
Let's also remove the changelog entry that was added in #60347, since no changes will be included in the next release:
I'm unsure if it's okay to do like that since we are changing the min for all sides?
Seems to be fine because revalidation doesn't occur until the next user interaction with the given input. We can revisit if it causes issues in specific environments, but it's working fine in Chrome/Safari/FF at least.
packages/block-editor/src/components/global-styles/dimensions-panel.js
Outdated
Show resolved
Hide resolved
84f86be to
a576b63
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks so much for the help and the tests here, @mirka ! |
…panel.js Co-authored-by: Lena Morita <lena@jaguchi.com>
a576b63 to
8e026d6
Compare
What?
Merging #60347 broke the Box Control component, not allowing for
inputPropsto be passed. It also made the changes directly into the component, instead of only in the instance where the changes are needed. This aims to fix both things.Why?
It was a bug, we don't want to break the component usage :D
How?
We added unit tests to cover the failure and moved the changes to the dimensions panels, where we need the drag control and to happen and setting the min value instead of directly in the component
Testing Instructions
#60347 testing instructions should still be valid