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

Enqueue registered block assets and resolve iframe styles e2e failure #50185

Merged
merged 5 commits into from
May 1, 2023

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Apr 28, 2023

What

Temporary fix for iframe compat layer.

WordPress/wordpress-develop#4356 was merged into core at WordPress/wordpress-develop@5c247f7 recently. Since then, the packages/e2e-tests/specs/editor/plugins/iframed-inline-styles.test.js e2e test is failing because it uses the Wordpress trunk.

Why

The compat-layer of the iframe loads certain stylesheets based on whether they have a .wp-block-.

Before the change above, the stylesheets follow this order:

wp-block-library-css
wp-block-editor-content-css
wp-edit-blocks-css
iframed-inline-styles-style-css
test-iframed-inline-styles-editor-style-css
iframed-inline-styles-compat-style-css

After the change above, the stylesheets follow this order:

wp-block-library-css
wp-block-editor-content-css
wp-edit-blocks-css
iframed-inline-styles-compat-style-css
iframed-inline-styles-style-css
test-iframed-inline-styles-editor-style-css

Note how test-iframed-inline-styles-editor-style-css loads AFTER iframed-inline-styles-compat-style-css, which is the reason for the e2e to fail.

How

The core commit expose a bug in the iframe that we should address. This PR is a temporary fix to "revert" the core commit from Gutenberg.

An alternative would be to skip the test for now.

@oandregal oandregal marked this pull request as ready for review April 28, 2023 16:46
@andrewserong andrewserong added the [Type] Code Quality Issues or PRs that relate to code quality label May 1, 2023
Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting up this quick fix @oandregal! I just pushed a tiny commit to fix some PHP linting complaints, but otherwise this looks good and the priority of 1 matches the order in which callbacks were enqueued in trunk prior to the removal in WordPress/wordpress-develop#4356. I suppose it's still technically quite a bit higher priority being set to 1 rather than the first position in default 10, but I don't see that being an issue, and it sounds like it'd be a quick change to fix it up if it winds up causing problems.

LGTM! ✨

@andrewserong
Copy link
Contributor

This PR doesn't appear to cause any issues, gets the e2es passing again, and would be easy to revert if it does cause any problems. Since this will help unblock merging new PRs, I'll merge this in now. Thanks again for putting this PR up @oandregal!

@andrewserong andrewserong merged commit 3b86c62 into trunk May 1, 2023
@andrewserong andrewserong deleted the try/enqueue-registered-block-scripts-and-styles branch May 1, 2023 02:16
@github-actions github-actions bot added this to the Gutenberg 15.8 milestone May 1, 2023
@andrewserong andrewserong changed the title Enqueue the registered assets Enqueue registered block assets and resolve iframe styles e2e failure May 1, 2023
@oandregal
Copy link
Member Author

Created #50246 to track this, so we don't forget to remove it soon. cc @ellatrix

Mamaduka pushed a commit that referenced this pull request May 9, 2023
* Enqueue again the registered assets

* Document and protect against 6.1 and 6.2

* Make sure the action runs earlier, as if it was from core

* Make linter happy

* Fix linting issues

---------

Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
@ellatrix
Copy link
Member

It seems that the change in core did not only break the order in the iframe, but also the order outside the iframe. One could argue that the test plugin is not properly declaring dependencies, but I tried adding array( 'test-iframed-inline-styles-editor-style-css' ) to the compat stylesheet, and the dependency resolver is just removing the stylesheet completely.

So I'm now wondering if we should investigate the trunk change and somehow change the ordering back or revert that change.

@oandregal
Copy link
Member Author

Follow-up: WordPress/wordpress-develop#4498 is reverting the core change.

oandregal added a commit that referenced this pull request May 24, 2023
oandregal added a commit that referenced this pull request May 24, 2023
* Revert "Enqueue the registered assets (#50185)"

This reverts commit 3b86c62.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants