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

Spacing is cleared when editing block styles #112

Open
g-elwell opened this issue Oct 2, 2024 · 2 comments
Open

Spacing is cleared when editing block styles #112

g-elwell opened this issue Oct 2, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@g-elwell
Copy link
Member

g-elwell commented Oct 2, 2024

Expected Behavior

When navigating through the UI and editing different styles, no changes should be made unless specifically updated by a user.

Actual Behavior

When navigating to a block with spacing set in the theme.json, the styles update to clear the spacing.

Step-by-step reproduction instructions

  1. Set theme to Twenty Twenty Four
  2. Activate Themer
  3. Go to Appearance > Styles Editor
  4. Navigate to Blocks > Quote
  5. Notice the quote block will update to remove existing spacing values

Screenshots, screen recordings, code snippets

This is noticeable in the visual preview from #111 and less obvious when viewing the 'code preview'. However, note that the original spacing in theme.json is:

"spacing": {
  "padding": {
    "bottom": "calc(var(--wp--preset--spacing--30) + 0.75rem)",
    "left": "calc(var(--wp--preset--spacing--30) + 0.75rem)",
    "right": "calc(var(--wp--preset--spacing--30) + 0.75rem)",
    "top": "calc(var(--wp--preset--spacing--30) + 0.75rem)"
  }
},

But when navigating to the Quote block, the styles will show:

"spacing": {
  "padding": {
    "bottom": "0px",
    "left": "0px",
    "right": "0px",
    "top": "0px"
  }
}
Screen.Capture.on.2024-10-02.at.09-32-17.mp4
@g-elwell g-elwell added the bug Something isn't working label Oct 2, 2024
@g-elwell
Copy link
Member Author

g-elwell commented Oct 2, 2024

It's likely this is due to the component failing to parse the original value, perhaps due to use of calc or var. As well as (or instead of?) fixing this instance, we should prevent the value from updating when the parsing has failed, or we could unexpectedly hit this issue again.

@jordanharris-6
Copy link
Contributor

I've been looking into this for a bit and I thought I would update the issue with where im at. Seems to happen in this part of ThemerComponent.js http://bigbite.im/i/GZ74va

It does this wierd thing where on the last 2 renders of the load it sets the object to 0px 0px 0px 0px when the values its merging are not like that. I haven't been able to work out why its doing that yet but I will continue looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants