-
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
Spacer block: broken UX in clearing its "fixed" width/height input when inside a row/stack #51616
Comments
Thanks for reporting @hanneslsm, I am able to confirm as well. |
I just saw this happens also in the dimension controls (padding) for a button in the global styles. I guess this is not an issue of the spacer then but of the input field. |
I found a better fix for the spacer block height/width issue. The root cause was in packages/components/src/unit-control/index.tsx, where the unit was dropped when the value was empty. BeforeonChangeProp?.( '', changeProps ); AfteronChangeProp?.( `0${unit}`, changeProps ); This change ensures the unit is preserved, preventing it from resetting when the value is empty. cc: @mikachan @hanneslsm |
I'm unable to reproduce this with WP 6.7.1 and Gutenberg trunk. I’ve tried the with the controls for the spacer and the padding in global styles and others besides that. Can anyone confirm if this is still reproducible? |
Yes. It does not occur on the input for the margin but the height. |
@stokesman Try this
Original instructions dont mention it. |
@Mayank-Tripathi32, thank you! I can reproduce it now. This seems isolated to the Spacer block inside a flex layout. If I put other blocks inside the row/stack and try the same thing I cannot reproduce it. That makes me doubt the issue is with It looks like the culpable code is part of an effect here: gutenberg/packages/block-library/src/spacer/edit.js Lines 259 to 298 in be5ce8a
It gets executed anytime the value in the fixed width input is falsy, so an empty string triggers it. From what I gather it shouldn’t be triggered from changes in the input. I tried this little change and it seems to fix the issue: diff --git a/packages/block-library/src/spacer/edit.js b/packages/block-library/src/spacer/edit.js
index 1e0ffb9700..af84edf7ba 100644
--- a/packages/block-library/src/spacer/edit.js
+++ b/packages/block-library/src/spacer/edit.js
@@ -260,7 +260,7 @@ const SpacerEdit = ( {
isFlexLayout &&
selfStretch !== 'fill' &&
selfStretch !== 'fit' &&
- ! flexSize
+ flexSize === undefined
) {
if ( inheritedOrientation === 'horizontal' ) {
// If spacer is moving from a vertical container to a horizontal container,
That could use more testing to make sure it doesn’t interfere with what the effect is supposed to be doing but I’d opt to try that before the approach in your linked PR. |
Hey @stokesman , This also is present in style tab, Try to see if you get same behaviour in padding and margin here. |
I find it’s different with a similarity. The difference is that the |
I see, maybe this could fix the issue? #68734 |
I take it you mean the PR linked to that issue. That issue looks distinct—it involves a range input whereas this issue does not. I suppose that linked PR might happen to fix this but I don’t think it’s right approach for either issue. The |
@stokesman This does seems to be the problem, Should I change the approach in PR?
I will explore on this and see. |
I do suggest a changed approach. It’s up to you if you want to revamp your PR or make a new one 🙇. |
Got it, I will open another PR/Issue for this problem. Additional Test: (Expected)
|
Description
Upon clearing the input, it inserts a
0
instantly and if the unit is other thanpx
it’s changed back topx
.Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Screen.Recording.2023-06-18.at.09.54.34.mp4
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: