-
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
Remove experimental flag from navigation and file blocks to use the Interactivity API (as private) #51266
Remove experimental flag from navigation and file blocks to use the Interactivity API (as private) #51266
Conversation
Size Change: -3.42 kB (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
Flaky tests detected in b318b9f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5191523823
|
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 detected a couple of problems related to the files and directives:
- When there are no submenus, we should ignore
openSubmenusOnClick
andshowSubmenuIcon
and treat them as if they werefalse
. - When
overlayMenu
isfalse
,openSubmenusOnClick
isfalse
butshowSubmenuIcon
istrue
, the directives are not being injected into thenav
. I don't know why. Looking at the code I couldn't spot the problem.
https://www.loom.com/share/2bd82cfd63c3484e92895670be31c57e
Is there an easy way to know if there are any submenus?
Thanks a lot for the in-depth review and the video 🙂
Oh, I think it is because of this conditional. I guess this could be solved adding the directives to that element or adding
First thing that comes to my mind is using the Tag Processor, checking if there is an element with the |
I just updated the code to solve the issues you mentioned. Let me know if that's okay 🙂 |
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.
LGMT now! Thanks, Mario 🙂
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.
LGMT now! Thanks, Mario 🙂
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
…nteractivity API (as private) (WordPress#51266) * Remove experimental flag from file block * Remove experimental flag from navigation block * Fix ESC triggering closeMenu more than expected * Update experiments page label * Don't send JS files when there are no submenus * Add `data-wp-interactive` to submenus * Change has_submenu conditional to include subpages * Update experimental label Co-authored-by: Luis Herranz <luisherranz@gmail.com> * Use Tag Processor instead of `strpos` * Format `index.php` file --------- Co-authored-by: Luis Herranz <luisherranz@gmail.com>
What?
I opened a while ago a similar pull request to remove the Interactivity API experimental flag completely. However, as the navigation and the file blocks have already been experimental for a while, and they are not adding new functionalities, I believe we can remove the experimental flag from them while keeping it for other blocks using the Interactivity API.
Keep in mind that it doesn't mean exposing the Interactivity API. It remains private only available for these blocks. This means that external blocks/plugins cannot use it, and we can keep experimenting and iterating.
Why?
At this moment, users can only test the navigation and the file blocks using the Interactivity API if they activate the Experimental flag on the Gutenberg Experiments page.
How?
These are the steps I took:
script-loader.php
from theload.php
file.viewScript
field of theblock.json
of the Navigation and File blocks to read the interactivity.js file.view.js
files.index.php
of the Image and File blocks.Apart from that, I fixed a small bug where the
closeMenu
function was being triggered more than expected when pressing the ESC key when the menu was closed.Testing Instructions