-
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 page list to expand in list view #45776
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +2.21 kB (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Discussing the bug making the post dirty with @talldan he pointed to how templated blocks work where the template is placed using replace blocks which is a persistent change: gutenberg/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js Lines 84 to 96 in fecc1d2
This implementation sets the template asynchronously which is after the initial render so the post is marked as dirty, as it should, but not in this case. Dan suggested that to try and manually replace blocks instead of using a template. It remains to be seen which way is best. |
@@ -81,6 +82,7 @@ export default function useInnerBlockTemplateSync( | |||
); | |||
|
|||
if ( ! isEqual( nextBlocks, currentInnerBlocks ) ) { | |||
__unstableMarkNextChangeAsNotPersistent(); |
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'm not sure if patching the useInnerBlockTemplateSync
hook for a single use case is a good idea 😅
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.
It's not only this, we've hit this before: see #45843
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.
Can we remove this from this PR and wait on the decision in #45843?
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'll try to rebase on that or something. b/c otherwise this PR does not work.
I assume you tried using the Page Link block? |
Thanks for working on this, it's looking great. I just left a few questions about things I didn't understand. |
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.
Some things I noticed.
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.
As things stand I don't think this is working 😞
I cleared all my menus then added a new Nav block.
- a new Nav was automatically created
- I saw a Page List in the offcanvas
- I tried clicking on Page List in the offcanvas but I couldn't seem to select it
- I went to the main List View and clicked on Page List. I was able to selected it.
Basically everything seems out of sync as per the video.
Thanks for the testing @getdave 🙇🏻
None seem to be problems of this PR. |
72144ea
to
f408ea2
Compare
key={ id } | ||
className={ classnames( 'wp-block-pages-list__item', { | ||
'has-child': hasChildren, | ||
'wp-block-navigation-item': isNavigationChild, |
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.
It seems like there is quite a lot of overlap between this file and the navigation link - they need to share the same layout. Is there anything we can do to ensure they stay in sync?
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 think this has been an issue in core/page-list
for a while. The problem has now just moved to the item
. Am I right @draganescu ?
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.
Yes. Page list item is mostly a copy of the old PageItems component used inside the page list block.
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 created a follow up issue for this here: #46050
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 is testing well for me. I have a few small concerns about sharing the layout with the navigation-link block, but nothing that should stop you merging.
As long as that works for the Page List (parent) block itself.
The code for this autosave was written specifically to check for a dirty state on the blocks that are pased into the component but it is a little bit "hacky". Did you create an Issue to track this bug? I think that's important 🙏 |
What's the status on this one? Blocked due to the sync problems with inner blocks? |
Yes, @getdave @scruffian should we merge with the known bug that adding a page list makes the post dirty? Should we wait for #45843 ? |
… json configuration. Co-authored-by: Ben Dwyer <[email protected]>
f408ea2
to
86d80e0
Compare
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 is looking good. I think we should deal with the edit experience in a followup: #46051
What?
Closes #45482
Adds the ability to the page list block to expand in the list view.
Why?
To reflect on the hierarchical structure that we're representing, particularly when the page list is used inside a navigation block.
How?
Add a new Page List Item block that can only appear as a chidl of Page List.
Testing Instructions
Screenshots or screencast
page-list-expands.mp4
Known issues: