-
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
Enable open on click for Page List inside Navigation. #34675
Conversation
Nice, this feels close to me! When the click option is toggled on, it appears to behave well for me in editor and frontend: We should probably use the When I have click toggled off, I see what looks like a button around the dropdown chevron: And something a bit confusing appeared to happen to me on the frontend when previewing. When I first tested, and created a hover menu, I got this to show: In this view, outside of the styling issue, focus also appeared to behave as intended. Then I enabled the click option and saved and previewed, but it required a few reloads for the effect to take. Once it finally stuck, I was unable to go back to hover-only. Same with hiding the chevron — this did not appear to save on the frontend. I might be experiencing a caching issue of sorts. But in any case, these steps failed for me:
Any idea what's up here? |
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.
Consolidates the front end script from Submenu with the Navigation one, so that it can be used by all child blocks of Navigation.
Thanks for this! It looks good 🎉
I noticed a few issues (screen caps from Firefox)
- In the editor, opening a submenu with multiple children opens all of them, and I can't seem to close the children by themselves.
- In the frontend, clicking on a sub-submenu closes the parent.
- At least on TT1, buttons are being styled in a few different ways depending on the settings; showing you what I see in a table below:
Open on click enabled | Open on click disabled | |
---|---|---|
Frontend | ||
Editor |
Thanks for reviewing and testing, folks! All the issues should now be fixed:
Let me know if I've missed anything 😅 |
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.
That is when Navigation is set to open on click, right? The problem is Twenty Twenty One has some super specific button styling, but there's not much we can do about that because we want to keep editor style specificity as low as possible. It will need to be fixed in the theme sooner or later. |
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.
That is when Navigation is set to open on click, right?
Indeed, it happens only when open on click is on.
there's not much we can do about that because we want to keep editor style specificity as low as possible. It will need to be fixed in the theme sooner or later.
With this in mind, I think this PR good to go :)
* trunk: (74 commits) Update docs for ClipboardButton component (#34711) Post Title Block: add typography formatting options (#31623) Bump plugin version to 11.5.0 Navigation Screen: Adjust header toolbar icon styles (#34833) Fix the parent menu item field in REST API responses (#34835) Rewrite FocusableIframe as hook API (#26753) Create Block: Remove wp-cli callout since not recommended and outdated (#34821) Global Styles: Fix dimensions panel default controls display (#34828) [RNMobile][Embed block] Enable embed preview for Instagram and Vimeo providers (#34563) Increase Link UI search results to 10 on Nav Editor screen (#34808) Prevent welcome guide overflow x scroll (#34713) Enable open on click for Page List inside Navigation. (#34675) [RNMobile] [Embed block] - Unavailable preview fallback bottom sheet title update (#34674) Add missing field _invalid in menu item REST API (#34670) Fix Dropdown/DropdownMenu toggle closing in all UAs (#31170) Navigation submenu block: replace global shortcut event handlers with local ones (#34812) Navigation Screen: Consolidate menu name and switcher (#34786) Remove parent and position validation from menu item REST API endpoint (#34672) Clean theme data when switching themes in the customizer (#34540) Components: add reset timeout to ColorPicker's copy functionality. (#34601) ...
|
||
// Styles for button toggles. | ||
button.wp-block-navigation__submenu-icon.wp-block-navigation__submenu-icon.wp-block-navigation__submenu-icon.wp-block-navigation__submenu-icon { | ||
padding: $grid-unit $grid-unit-20; |
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.
In my testing, this specificity wasn't necessary, and the added padding makes the chevron look very different from editor and frontend. I have a followup in #35030.
Description
Depends on #33775 and is currently pointed to that branch.
Enables open on click functionality for Page List blocks nested inside Navigation, whenever the open on click option is set in Navigation.
Consolidates the front end script from Submenu with the Navigation one, so that it can be used by all child blocks of Navigation.
When open on click is set, in the editor, submenus really open on focus. Because the block is server-rendered, it's tricky to add click events in the editor, and I think this is a good compromise. For mouse/touch users, it will work the same, whereas for keyboard users it shouldn't be a major issue because Select mode already allows skipping nested blocks when tabbing through items.
How has this been tested?
Add a Navigation block with a Page List inside it, and enable "open on click" in the Navigation block sidebar. Verify that Page List submenus open on click instead of hover/focus.
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist:
*.native.js
files for terms that need renaming or removal).