-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Self-nested blocks causing infinite recursion and crashing the editor #66090
Copy link
Copy link
Closed
Labels
[Feature] InserterThe main way to insert blocks using the + button in the editing interfaceThe main way to insert blocks using the + button in the editing interface[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
With the changes in #65700, self-nested or circular-nested blocks could cause infinite recursion resulting in crashing the editor.
cc: @youknowriad
Step-by-step reproduction instructions
- Register self-nested or circular-nested blocks. For example:
// Self-nested block
window.wp.blocks.registerBlockType( 'test/self-nested-block', {
title: 'Self-nested Block',
parent: [ 'test/self-nested-block', 'core/group' ],
save: () => {
return '';
}
} );
// Circular-nested blocks
window.wp.blocks.registerBlockType( 'test/self-nested-block-1', {
title: 'Self-nested Block #1',
parent: [ 'test/self-nested-block-2', 'core/group' ],
save: () => {
return '';
}
} );
window.wp.blocks.registerBlockType( 'test/self-nested-block-2', {
title: 'Self-nested Block #2',
parent: [ 'test/self-nested-block-1' ],
save: () => {
return '';
}
} );- Attempt to open the Inserter from the header toolbar. Note that if the problematic blocks already exist in the page content, the block editor will immediately crash after registering the blocks.
Note that if a visible parent block comes first, e.g. [ 'core/group', 'test/self-nested-block-2' ] instead of [ 'test/self-nested-block-2', 'core/group' ], the infinite recursion will not occur.
Screenshots, screen recording, code snippet
No response
Environment info
- WordPress 6.6.2
- Gutenberg 19.4.0
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Feature] InserterThe main way to insert blocks using the + button in the editing interfaceThe main way to insert blocks using the + button in the editing interface[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Type
Fields
Give feedbackNo fields configured for issues without a type.