Skip to content
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

Navigation Link - undo trap when added to inner block controllers via patterns. #33908

Closed
3 tasks done
Addison-Stavlo opened this issue Aug 5, 2021 · 2 comments
Closed
3 tasks done
Labels
[Block] Navigation Link Affects the Navigation Link Block [Type] Bug An existing feature does not function as intended

Comments

@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Aug 5, 2021

Description

Inserting a block pattern that contains navigation-link components inside an inner block controller (such as a template part or reusable block) creates an undo trap. After the pattern with the navigation link is added, it is no longer possible to undo any previous actions.

Example of the navigation section of a problematic pattern:

	<!-- wp:navigation {"orientation":"horizontal","itemsJustification":"center","align":"full","style":{"color":{"background":"#ececec"}}} -->
		<!-- wp:navigation-link {"label":"Home","url":"http:\/\/Home"} /-->
		<!-- wp:navigation-link {"label":"About","url":"http:\/\/About"} /-->
		<!-- wp:navigation-link {"label":"Contact","url":"http:\/\/Contact"} /-->
	<!-- /wp:navigation -->

related - #8119

Step-by-step reproduction instructions

  1. Register a new block pattern for a template part that contains navigation-link blocks in the markup (this can be done by adding to the list in lib/block-patterns.php ). an example of a pattern to add for in the array in lib/block-patterns.php:
		'tp-test'                 => array(
			'title'      => _x( 'tp test', 'Block pattern title', 'gutenberg' ),
			'blockTypes' => array( 'core/template-part/header' ),
			'content'    => '<!-- wp:group {"align":"full","style":{"color":{"background":"#ececec"}}} -->
			<div class="wp-block-group alignfull has-background" style="background-color:#ececec;"><div class="wp-block-group__inner-container">
			<!-- wp:navigation {"orientation":"horizontal","itemsJustification":"center","align":"full","style":{"color":{"background":"#ececec"}}} -->
			<!-- wp:navigation-link {"label":"Home","url":"http:\/\/Home"} /-->

			<!-- wp:navigation-link {"label":"About","url":"http:\/\/About"} /-->

			<!-- wp:navigation-link {"label":"Contact","url":"http:\/\/Contact"} /-->
			<!-- /wp:navigation --></div></div>
			<!-- /wp:group -->',
		),
  1. Load the site editor. Insert a "Header" block.
  2. Select "New header" from the placeholder block that was just inserted. The pattern you just added should appear as the first option, click "Choose" and create your template part.
  3. Press 'undo'. Notice you are unable to undo any previous actions in the editor.

Similarly, this can be reproduced in the post editor by adding this pattern inside a reusable block.

Expected Behavior

The 'undo' to work as expected, leading us back to the placeholder and any previous actions:

undo-works-on-core

Current Behavior

The undo action does not work:

no-undo

Is there an existing issue for this?

  • I have searched the existing issues

Have you tried deactivating all plugins except Gutenberg?

  • I have tested with all plugins deactivated.

Have you tried replicating the bug using a default theme e.g. Twenty Twenty?

  • I have tested with a default theme.
@Addison-Stavlo Addison-Stavlo added [Type] Bug An existing feature does not function as intended [Block] Navigation Link Affects the Navigation Link Block labels Aug 5, 2021
@talldan
Copy link
Contributor

talldan commented Oct 22, 2021

I think this was fixed by #34565. Thanks for flagging. I'll close it, but feel free to reopen if you can still reproduce.

@talldan talldan closed this as completed Oct 22, 2021
@Addison-Stavlo
Copy link
Contributor Author

I gave it a quick test and it seems to be fixed. Thanks @talldan !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Link Affects the Navigation Link Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants