-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 bug retrieving spacing.spacingSizes presets. #54084
Comments
Referencing: #39371 I know @richtabor, @mrwweb, @cbirdsong have been on this, not sure if they still work on it. |
Additional testing showed that it is not related to updating from 6.2 to 6.3. As this occured again on a fresh 6.3 site. What seems to be very strange behavior (sometimes it shows custom size with pixels, sometimes it shows tokens) appears to be the following phenomenon:
So indeed; we have a bug here. My advice would be: If If there is a use-case for it that I can't see, I suppose we might need a setting in the block.json to enable custom values for this block (which then removes spacingSizes) NB. Apologies for the comments and edits, but this seems like an important issue, as spacers are used in so many layouts. |
I've been unable to get the spacer block working with the spacing scale and have also noticed issues with it reverting back to px sizing on any mouse resizing/interaction.
💯 |
I could imagine dragging the handle snapping up/down to the next preset, but it seems like |
I don't know if it is related but some days ago i faced a similar problem with spacer. I wanted to show only the spacing preset in every blocks to ensure client cannot enter values. Every other block i tried show the expected behavior, but spacer does the opposite, showing only the input where to insert custom values. The react code that is think is related to this issue is gutenberg/packages/block-library/src/spacer/edit.js Lines 91 to 94 in 0792221
because in the return jsx there is gutenberg/packages/block-library/src/spacer/edit.js Lines 339 to 348 in 0792221
I suggest also to rename |
Confirming this remains very broken with CleanShot.2024-01-29.at.17.38.02.mp4On a theme with custom spacing sizes disabled, it still adds a block with "100px" as the default value, and the only way to get to the presets is:
CleanShot.2024-01-29.at.17.45.46.mp4So, in my estimation, these things need to happen:
@Humanify-nl Can you share the code you used to register those variations? If you can register one with a null/empty value, then it may just show the presets by default. |
Description
Before 6.3 update, I used the spacer block with 4 block variations for preset sizes (with a js filter). But, when I updated to 6.3 it showed the spacing.spacingSizes that I had specified for gaps & margin! Super nice!
I was very happy to see that these are now used for the spacer block. At least... I thought so. Because, after I removed all the variations and worked on some other things, the spacer presets are gone again.
For some reason, the spacer blocks that existed before 6.2 and after updating to 6.3 did have the presets. But, adding a new spacer block does not have the presets.
Looking at the source code of the block I see that spacing.spacingSizes is actually retrieved.
https://github.com/WordPress/gutenberg/blob/1c09fae498d2bf073975454d66a4c89bc3ede8d8/packages/block-library/src/spacer/controls.js#L28C1-L28C60
But somehow they are not working! I have tried setting the spacingSizes specifically on
settings.blocks.core/spacer
This is how I load variables in theme.json (the supplied var(--spacing--token--1) are processed with media queries, this has never given me issues before).
Step-by-step reproduction instructions
I suppose:
Screenshots, screen recording, code snippet
Edit: I found another theme that was still in 6.2 and can now demonstrate this weird behavior, just after update to 6.3:
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: