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

Duplicating a template part makes the site editor freeze #43760

Closed
talldan opened this issue Sep 1, 2022 · 8 comments · Fixed by #44176
Closed

Duplicating a template part makes the site editor freeze #43760

talldan opened this issue Sep 1, 2022 · 8 comments · Fixed by #44176
Assignees
Labels
[Block] Template Part Affects the Template Parts Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended

Comments

@talldan
Copy link
Contributor

talldan commented Sep 1, 2022

Description

Duplicating a template part seems to make the site editor hang.

There's no visible error, but I think duplicating triggers an infinite recursion and the UI hangs.

Step-by-step reproduction instructions

  1. Open the site editor
  2. Select the header or footer
  3. From the block toolbar open the options dropdown and select Duplicate
  4. Continue editing in the site editor

Expected: It's possible to continue editing
Actual: After a while the site editor freezes and is unusable

Screenshots, screen recording, code snippet

No response

Environment info

Mac OS / Brave
Tested using latest Gutenberg trunk (at 2de4197)

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

@talldan talldan added [Type] Bug An existing feature does not function as intended [Block] Template Part Affects the Template Parts Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Sep 1, 2022
@talldan talldan changed the title Duplicating a template part makes the site editor hang Duplicating a template part makes the site editor freeze Sep 1, 2022
@rku4er
Copy link

rku4er commented Sep 4, 2022

I have a similar issue when trying to insert a template part that already exists. So it's not possible to have two same template parts in a page template. Interesting that in some cases the editor just replaces the existing template part with the message "This block has encountered an error and cannot be previewed." without freezing.

@annezazu
Copy link
Contributor

annezazu commented Sep 8, 2022

I tried to replicate in Chrome using 14.0.2 and couldn't. cc @ironprogrammer and @ndiego in case ya'll have time to replicate/test more.

testing.mov

@annezazu
Copy link
Contributor

annezazu commented Sep 9, 2022

I can replicate this with Safari. The above is with Chrome. Seems browser specific!

@ciampo
Copy link
Contributor

ciampo commented Sep 9, 2022

I definitely encountered this problem in the site editor while testing the Popover component, on latest Chrome on MacOS.

@spencerfinnell
Copy link

I have seen this as well, in Chrome. Sometimes the tab completely crashes, other times there is a lot of lag. Chrome 105.0.5195.102 (Official Build) (arm64)

@annezazu annezazu added the [Priority] High Used to indicate top priority items that need quick attention label Sep 10, 2022
@talldan
Copy link
Contributor Author

talldan commented Sep 12, 2022

Don't ask me how I figured it out, but the problem seems to go away if I comment out this setAttributes call in the group block's code:

useEffect( () => {
if ( layoutType ) {
__unstableMarkNextChangeAsNotPersistent();
setAttributes( { layout: { ...layout, type: layoutType } } );
}
}, [ layoutType ] );

So I think this is actually a group block bug. That's probably why it couldn't be consistently reproduced.

To test this I duplicated the Twenty Twenty Two theme's 'Header (Dark, small)' template part in the home template. When duplicating and logging the value of layoutType this is what's logged:
Screen Shot 2022-09-12 at 3 11 58 pm

@talldan
Copy link
Contributor Author

talldan commented Sep 12, 2022

TBH, I don't really understand what that code does. It seems to set the attribute to the value it already has.

That was observed in the PR review here - https://github.com/WordPress/gutenberg/pull/42763/files#r947365766, but I think we need a deeper understanding of why the effect was added.

cc @tellthemachines , @glendaviesnz.

edit: took a deeper dive and left some advice on the comment thread there - https://github.com/WordPress/gutenberg/pull/42763/files#r968097246

@talldan
Copy link
Contributor Author

talldan commented Sep 13, 2022

Fix in #44103

@ockham ockham moved this from Triage to Todo in WordPress 6.1 Editor Tasks Sep 13, 2022
Repository owner moved this from Todo to Done in WordPress 6.1 Editor Tasks Sep 16, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
No open projects
7 participants