-
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
Fix submenu layout in navigation page list. #34342
Conversation
Size Change: -2 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
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.
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.
This tests well for me, I also verified that things updated properly when moving blocks around. Feel free to 🚢
Overall, the need for the isNavigationChild
attribute is interesting and something to keep an eye on. With this property set, it's possible for us to serialize this in an incorrect way (say that the page list is a navigation child when it's not). A simple way of doing this would be to edit the post in the code editor with the following line:
<!-- wp:page-list {"isNavigationChild":true} /-->
The render callback probably doesn't have any information about block parents, so if we end up needing a similar solution elsewhere, it may be worth investigating if it makes sense to provide additional information, or explore an alternative.
Oooh I never thought of that! You'd have to save it in the code editor and exit immediately though, because switching back to the visual editor will change the value to
We discussed passing the actual classnames down instead, but due to our use of |
Description
With the classname changes in #33918, the
isNavigationChild
attribute was added to the Page List block, so it can render with the navigation-specific classnames when necessary. But because the attribute is being updated inside auseEffect
, it isn't present on first render ofPageListEdit
, resulting in Page List blocks not getting the right classnames when first added to the Navigation block.This PR fixes the issue by updating
isNavigationChild
before the component first renders.How has this been tested?
Create a few pages on your test site, and set a few of them to be children of another page.
Add a new navigation block to a post, and choose "Add all pages".
Add another navigation block, choose "Start empty", and then add a Page List block inside it.
Verify that in both cases, the Page List renders child pages correctly as submenus of their parents.
Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).