-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block editor: Self nesting and circular nesting block fix #66121
Block editor: Self nesting and circular nesting block fix #66121
Conversation
…etting into the recursion.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @SH4LIN! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
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.
Changes look good to me. Do you think we can add some unit tests?
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 confirmed that nested blocks cannot be inserted at the root level, and I've also confirmed the browser warning when registering a block that is itself a parent.
At the very least, we may need to add unit tests for registering blocks here.
if ( | ||
settings?.parent && | ||
Array.isArray( settings.parent ) && | ||
settings.parent.length === 1 && | ||
settings.parent[ 0 ] === name | ||
) { |
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.
if ( | |
settings?.parent && | |
Array.isArray( settings.parent ) && | |
settings.parent.length === 1 && | |
settings.parent[ 0 ] === name | |
) { | |
if ( settings?.parent?.[ 0 ] === name && settings.parent.length === 1 ) { |
Nit: I don't have a strong opinion, but this might be simpler.
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.
Sure, I'll update the code and add test case
@t-hamano @youknowriad I have updated the code LMK if any further changes are required |
Thanks for your contribution :) |
Co-authored-by: SH4LIN <sh4lin@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: yuliyan <yuliyan@git.wordpress.org>
closes #66090
What?
false
.false
.Why?
How?
false
.false
.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Fixes/Covers