Fix: Allow style variations to override blockGap#74513
Fix: Allow style variations to override blockGap#74513BrajamohanDas-afk wants to merge 26 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Ndimande-dev, @hrishikesh2810, @EldarAgalarov. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @BrajamohanDas-afk! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
…pt (#70523) Co-authored-by: SainathPoojary <sainathpoojary@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Refactoring the dom-ready package tests by replacing a custom MockDocument interface and direct property assignments with a simpler Object.defineProperty approach to mock the document's readyState property. ---------- Co-authored-by: SirLouen <sirlouen@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
* Add all fields to the block fields form by default * Adjust appearance in patterns, only show first field and use a non-block title for standalone blocks * Add comment * Hide dropdown for non-collapsed mode * Add doc block comment for BlockFields component * Fix typo ---- Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
|
Thanks for the PR! I'm not convinced this is the correct approach though. Block style variations should be output by The main reason this doesn't work out of the box is that gap isn't part of I put together a draft alternative solution in #74529. I'm not 100% sure that's the best approach either 😅 but hopefully it's a start in the right direction (fixing this in the style variation logic itself, instead of the layout logic) |
|
@tellthemachines Okay, I’ll go through your approach and then modify the PR. |
Co-authored-by: shimotmk <shimotomoki@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: rutviksavsani <rutviksavsani@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
* Fully resolve some intra-package import paths * Add changelog entry Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
* Storybook: Fix introduction for source code link * Fix description of site structure Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: shimotmk <shimotomoki@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
* Revert "`@wordpress/ui` `Button`: add `destructive` tone (#74463)" This reverts commit d190fc7. * Keep some better docs --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Unlinked contributors: Ndimande-dev. Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Unlinked contributors: dimitrop. Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
* Refactor from ariakit to base ui button component * Remove button link storybook example * CHANGELOG * Use internal ComponentProps type utility --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Implementation the new approch: following the direction in #745291. PHP: Enable blockGap Setting for VariationsAdd to the $config = array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'spacing' => array(
'blockGap' => true,
),
),
'styles' => array(
'elements' => $elements_data,
'blocks' => $blocks_data,
),
);2. PHP: Process Gap as Protected Property2a) Update
|
|
If this is ok then, i will go with the pr. |
| - `AnglePickerControl`: Migrate styles from Emotion to a CSS module ([#73786](https://github.com/WordPress/gutenberg/pull/73786)). | ||
| - `Menu`: Clean up popover wrappers ([#74207](https://github.com/WordPress/gutenberg/pull/74207)). | ||
| - `Button`, `DateCalendar`, `DateRangeCalendar`, `CheckboxControl`, `Panel`, `Placeholder`: Remove outdated vendor prefix properties in CSS ([#74213](https://github.com/WordPress/gutenberg/pull/74213)). | ||
| - Updated `fast-deep-equal` imports for compatibility with strict Node.js resolution ([#74530](https://github.com/WordPress/gutenberg/pull/74530)). |
There was a problem hiding this comment.
Let's make sure that all CHANGELOG entries are kept in the "Unreleased" section, at the top of the file
|
It looks like there are a lot of unnecessary commits, probably due to a failed rebase or merge 😄 It might be better to close this PR and move forward with #74529. Thanks for your efforts, @BrajamohanDas-afk! If you don't mind, I'd be happy if you could test #74529. |
What?
Fixes style variations being unable to override the
blockGapproperty for blocks.Closes #72318
Why?
Currently, block style variations can successfully override visual properties like background colors, but fail to override layout spacing properties like
blockGap. This is because the layout engine calculates spacing values before style variation data is considered.This creates an inconsistent developer experience where some style variation properties work while others are silently ignored.
How?
Added a check in
lib/block-supports/layout.phpto retrieveblockGapfrom active style variations before falling back to block-level or global values.The fix implements the correct priority order:
blockGapblockGapblockGapTesting Instructions
theme.jsoncontaining:2.Create a style variation file in styles/no-gap.json:
3.Create a new post/page with two Group blocks
4.Add paragraphs inside each Group
5.Apply the "No Gap" style variation to the second Group
6.View the page on the frontend
Before this fix: Second group has red background but still 50px spacing.
After: First group has 5px spacing, second group has blue background with 50px spacing.