-
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
Block gap: Check for splitOnAxis in the onChange callback #39788
Conversation
… object only when the boxvalue control is activated. Rename vars for clarity Add some tests for getGapBoxControlValueFromStyle because we call it directly in flow.js (even though the tests for getGapCSSValue cover it indirectly)
Size Change: +14 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick follow-up @ramonjd!
This looks like a good approach to me — preserves the string based approach for blockGap
unless the block has opted in to axial controls 👍
I'd be keen personally to have a look at seeing if we can roll out the axial controls to the gallery block, too — I'm happy to take a look in a separate PR since I was planning to take a look at the blockGap support in global styles anyway. But this PR looks like a good fix for now!
✅ Gallery block uses string values for blockGap
✅ Social links block still uses axial controls and the box values
✅ Switching off axial controls for the social links block successfully gets it to serialize string values for blockGap
Looks good in the editor and frontend to me, and the markup in post-content looks like:
<!-- wp:gallery {"linkTo":"none","style":{"spacing":{"blockGap":"9px"}}} -->
...
<!-- wp:social-links {"style":{"spacing":{"blockGap":{"top":"10px","left":"5px"}}}} -->
LGTM (just a tiny linting issue that looks like Prettier needs before this can be merged). Thanks again! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Fixed the Gallery issue and the horizontal/vertical split also still worked on social icons
Resolves #39778
What?
#37736 introduced a bug whereby we always returning a box control value for block gap, even when
splitOnAxis
and thereforeBoxControl
component were inactive.Why?
The consequence of the bug was that blocks that do not opt into split axis gap values, such as the Gallery Block, still expect a string value for gap and will bork when they receive an object.
They don't know what to do with it, kinda like me with a Rubik's cube.
How?
This PR checks whether
splitOnAxis
is active and returns a string or box control value appropriately.I also tested that, if we roll back axial gap support on the Social Links block, a box control-like value in the block styles will be converted back to a string.
Testing Instructions
Use a theme that has support for blockGap, e.g., TwentyTwentyTwo
--wp--style--unstable-gallery-gap
should be a string, for example'20px'
.npm run test-unit packages/block-editor/src/hooks/test/gap.js
Here's some test HTML
Mar-28-2022.10-05-39.mp4