-
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
Implement the nested block behavior in list block v2 #39487
Conversation
Size Change: +224 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
export default function save() { | ||
return ( | ||
<ul { ...useBlockProps.save() }> | ||
<InnerBlocks.Content /> |
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.
Could we add some checks to return null if there are no inner blocks? It is very easy to create an empty list item for the user is very hard to remove. Or maybe we can automatically remove the list block if it becomes empty?
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.
we should add a shortcut later that removes it on backspace
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.
For me this is a good base implementation to land and split the rest of the work in parallel. Thanks Riad!
const innerBlocksProps = useInnerBlocksProps( blockProps, { | ||
allowedBlocks: [ 'core/list' ], | ||
} ); |
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.
Nitpick: { allowedBlocks: [ 'core/list' ] }
could be moved to a constant outside of the component to avoid recreating it on every render.
e5b0031
to
74e079f
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.
Nothing to add here, just glad to see the experiment taking off!
"content": { | ||
"type": "string", | ||
"source": "html", | ||
"selector": "li", |
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.
Indentation here is off.
Related #6394
What?
This PR implements the logic for the list block v2 (with inner blocks). It adds the base save/edit for list and list item blocks.
How?
At the moment, the block is very rough, I decided explicitly to only focus on:
There's a lot of things to be implemented here to make this block more usable, the idea is that now that we have the list block and basic behavior in place, we can potentially work in parallel if needed on some of these points:
Testing Instructions
1- Enable the "list block v2" experiment
2- Insert a list block
3- You can use appenders and such (regular inner blocks UI) to insert list items and nested lists (interaction is very rough without keyboard support)
4- Make sure the produced markup is correct.
Screen.Recording.2022-03-16.at.9.25.50.AM.mov