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

Inline Block Styles are not added when not authenticated. #26

Open
StevenDufresne opened this issue Apr 21, 2022 · 3 comments
Open

Inline Block Styles are not added when not authenticated. #26

StevenDufresne opened this issue Apr 21, 2022 · 3 comments

Comments

@StevenDufresne
Copy link
Collaborator

When the user is not logged in, some wp-block-{block_name} styles are not applied inline. This causes discrepancies with the editor experience and makes it hard to style the page properly and the unauthenticated page looks broken.

I spent some time looking into it but wasn't able to figure out the reason it's not working properly.

Start:
https://github.com/WordPress/gutenberg/blob/56c69e1f2e3e14e9feeeb5351f7436fd11a861fd/lib/blocks.php#L185

I modified the code to make sure the styles are being added, and they are, but they don't come out the other end when the page is rendered.

@StevenDufresne StevenDufresne changed the title Inline Block Styles are not adding when not authenticated. Inline Block Styles are not added when not authenticated. Apr 21, 2022
@mylawacad
Copy link

Experience the same issue

@ryelle
Copy link
Contributor

ryelle commented Nov 13, 2024

I've just pushed a change that removes the "separate block assets" loading 979f5d8. This loads all registered block styles on the page, regardless of usage detection. I'm not sure if being logged in affects anything more than caching, but what I imagine was happening before was the style loader was trying to read the blocks from the current page content, while we actually display blocks from gutenberg-content.php. If those have different blocks, that could explain why some block styles were not loading.

Preventing should_load_separate_core_block_assets will always load all registered styles. I think the specific block style loading here can be removed now, but I'd like a gut-check before going ahead.

/*
These styles are usually registered by Gutenberg and register properly when the user is signed in.
However, if the use is not registered they are not added. For now, include them, but this isn't a good long term strategy
See: https://github.com/WordPress/wporg-gutenberg/issues/26
*/
wp_enqueue_style( 'global-styles' );
wp_enqueue_style( 'wp-block-library' );
wp_enqueue_style( 'wp-block-image' );
wp_enqueue_style( 'wp-block-group' );
wp_enqueue_style( 'wp-block-heading' );
wp_enqueue_style( 'wp-block-button' );
wp_enqueue_style( 'wp-block-paragraph' );
wp_enqueue_style( 'wp-block-separator' );
wp_enqueue_style( 'wp-block-columns' );
wp_enqueue_style( 'wp-block-cover' );
wp_enqueue_style( 'global-styles-css-custom-properties' );
wp_enqueue_style( 'wp-block-spacer' );

Before After
Image Image

@StevenDufresne
Copy link
Collaborator Author

It's a pretty thin test surface. You'll know quickly whether it will work or not. Go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants