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

Option to disable inline style for Group block #35811

Open
coreyworrell opened this issue Oct 20, 2021 · 1 comment
Open

Option to disable inline style for Group block #35811

coreyworrell opened this issue Oct 20, 2021 · 1 comment
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Enhancement A suggestion for improvement.

Comments

@coreyworrell
Copy link
Contributor

What problem does this address?

When using the "Inherit default layout" option for a group block (currently the only way to allow inner blocks to have wide/full alignment options), extra styles are appended to the DOM right after the group. Some themes do not need these extra styles (think CSS grid) and the <style> element in the DOM messes with some styles (.wp-block-group + .whatever).

What is your proposed solution?

Allow these styles to be "dequeued" or not output. I don't want to allow any custom content/wide widths for groups anyways (or if we did it would certainly come from a limited set and not just "free form" input that accepts any number).

@skorasaurus skorasaurus added the [Block] Group Affects the Group Block (and row, stack and grid variants) label Oct 20, 2021
@coreyworrell
Copy link
Contributor Author

coreyworrell commented Feb 5, 2022

This is still an issue in 5.9. I see the <style> has been moved down to bottom of <body>, but I still don't see a way to disable the style completely. I am using CSS grid and the CSS that is generated completely ruins the layout.

For now I am just using this to disable:

remove_filter('render_block', 'wp_render_layout_support_flag', 10, 2);

Edit: the above will not work actually because it also removes other layout features for other blocks (button alignment, etc).

Double edit: now using this filter instead:

remove_filter('render_block', 'wp_render_layout_support_flag', 10, 2);
add_filter('render_block', function (string $content, array $block): string {
    if ($block['blockName'] !== 'core/group') {
        $content = wp_render_layout_support_flag($content, $block);
    }

    return $content;
}, 10, 2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants