-
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
Use interactivity API for Navigation and File blocks only in Gutenberg #51694
Use interactivity API for Navigation and File blocks only in Gutenberg #51694
Conversation
Size Change: +9.74 kB (+1%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7933cea. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5322144280
|
I tested and works as expected. |
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.
I've just tested it and it seems to work well 👍️
WordPress#51694) * Add conditional to navigation block * Add conditional to file block * Skip `view-modal` if `should_load_script` is false * Fix typo * Apply conditional in `block_type_metadata` filter
What?
Add a conditional to only use the Interactivity API in the Navigation and File blocks only when Gutenberg is activated.
Why?
As the Interactivity API version won't be included in WordPress yet, we need this conditional so it uses the previous version in WordPress but it uses the Interactivity API if Gutenberg is activated.
How?
I reverted the changes made in this pull request, adding back the old
view.js
files, and usedefined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN
to use the Interactivity API dynamically. Basically, if Gutenberg is activated, it is:viewScript
file tointeractivity.js
through theblock_type_metadata
filter.If Gutenberg is not activated, it is using the previous JS files and the attributes used by Micromodal.
I kept the logic added in the mentioned pull request to dynamically load the scripts because I believe it applies to both cases. If I am not mistaken, in the current version of WordPress, the scripts are always loaded even if they are not needed. So it should be an improvement although it is not perfect.
Testing Instructions
We can simulate it by toggling this variable. For both the Navigation and File blocks we have to check:
When
IS_GUTENBERG_PLUGIN
is false:view.js
files are loaded.interactivity.js
,vendors.js
, andruntime.js
).Show inline embed
is activated, it should show a preview only on desktop and not on mobile.When
IS_GUTENBERG_PLUGIN
is true:view.js
files are NOT loaded.Show inline embed
is activated, it should show a preview only on desktop and not on mobile.