Skip to content
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

Input Fields: Unit jumps to px when set to 0 #51616

Open
hanneslsm opened this issue Jun 18, 2023 · 3 comments · May be fixed by #68212
Open

Input Fields: Unit jumps to px when set to 0 #51616

hanneslsm opened this issue Jun 18, 2023 · 3 comments · May be fixed by #68212
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Bug An existing feature does not function as intended

Comments

@hanneslsm
Copy link

Description

see below

Step-by-step reproduction instructions

  1. Add a spacer
  2. set unit to vh
  3. remove the values, so that you can add a new value
  4. a 0 gets automatically added and the unit jumps back to px

Screenshots, screen recording, code snippet

Screen.Recording.2023-06-18.at.09.54.34.mp4

Environment info

  • WP 6.2.2
  • GB 16

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

@ndiego ndiego added [Block] Spacer Affects the Spacer Block [Type] Bug An existing feature does not function as intended labels Jun 20, 2023
@ndiego
Copy link
Member

ndiego commented Jun 20, 2023

Thanks for reporting @hanneslsm, I am able to confirm as well.

@hanneslsm
Copy link
Author

hanneslsm commented Jul 26, 2023

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'm going to rename the title. @ndiego Could you please change the label? Thanks! (Maybe even a ticket for the UX & Polish Board? :) )

@hanneslsm hanneslsm changed the title Spacer: Unit jumps to px when set to 0 Input Fields: Unit jumps to px when set to 0 Jul 26, 2023
@mikachan mikachan added [Feature] Layout Layout block support, its UI controls, and style output. and removed [Block] Spacer Affects the Spacer Block labels Nov 6, 2023
@mikachan mikachan added this to Polish Nov 6, 2023
@mikachan mikachan moved this to Needs development in Polish Nov 6, 2023
@Mayank-Tripathi32
Copy link
Contributor

Mayank-Tripathi32 commented Dec 20, 2024

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'm going to rename the title. @ndiego Could you please change the label? Thanks! (Maybe even a ticket for the UX & Polish Board? :) )

I fixed the spacer block height/width issue in packages/block-editor/src/components/child-layout-control/index.js. It seems the layout styles issue may not be directly related, but I will investigate further. Additionally, I’m opening a draft PR to test the spacer block fix.

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.

Before

onChangeProp?.( '', changeProps );

After

onChangeProp?.( `0${unit}`, changeProps );

This change ensures the unit is preserved, preventing it from resetting when the value is empty.

cc: @mikachan @hanneslsm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Bug An existing feature does not function as intended
Projects
Status: Needs development
Development

Successfully merging a pull request may close this issue.

4 participants