WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.39k stars 4.15k forks source link

Site Editor: templates do not save if already edited in another theme #28951

Closed Sandstromer closed 3 years ago

Sandstromer commented 3 years ago

Description

In the Site Editor, when editing a template or a template part, unable to save if template or template part already exists as a previously edited template from another theme.

Step-by-step reproduction instructions

Install more than one FSE enabled theme e.g. TT1 Blocks and Q Activate either theme. Go to Site Editor and make changes to a template part (e.g. header) or a template (e.g. index), save changes by clicking Update Design. Exit the Site Editor, go to Appearance > Themes and switch themes to the other FSE theme. Go back into Site Editor and make changes to a template e.g. if you previously edited header in TT1 Blocks theme, then edit the header in Q theme. Click Update Design to save and the button should change state to disabled to signify that the changes have been saved. Notice the button stays active. Exit the Site Editor and notice the 'This page is asking you to confirm that you want to leave - data you have entered may not be saved.' message. Click 'Leave Page' to exit the Site Editor. View the live site and notice how the edited template has not changed. Go to Appearance > Themes and switch back to TT1 Blocks theme, view the live site and notice how the template has now changed to the template that we were trying to edit when the Q theme was active.

Expected behaviour

The template or template part should only save for the active theme, not another theme with the same previously edited template name.

Actual behaviour

The template or template part is saved for the wrong theme.

Screenshots or screen recording (optional)

Code snippet (optional)

WordPress information

Device information

Sandstromer commented 3 years ago

@paaljoachim would you also consider tagging with the [Priority]High and [Type]Bug labels?

paaljoachim commented 3 years ago

Hi @Sandstromer

I will instead ping folks who work with Full Site Editing so that they are alerted to this issue: @jameskoster @Addison-Stavlo @aristath

I also added the Needs testing label so full site editing developers can take a look.

Sandstromer commented 3 years ago

Thank you for the explanation @paaljoachim I'm new to this so it definitely helps and is much appreciated.

paaljoachim commented 3 years ago

Thank you for finding this bug and reporting it here! Have a great continued weekend!

carolinan commented 3 years ago

I can confirm that I am able to reproduce this.

annezazu commented 3 years ago

Confirming that I can replicate this as well.

carolinan commented 3 years ago

Highlighting this because I think this must be solved for the MVP @mtias @david-szabo97

Addison-Stavlo commented 3 years ago

That is super funky! I can repro as well:

cc @youknowriad @jeyip to add to the list of pings for folks that may have ideas.


Expanding on what I can repro above. It looks like those template parts always have the expected ID in the editor active-theme//tp-slug. But in step 2 it is saving to theme-A//header instead of theme-B//header (even though the block has this ID and save panel sees this as the entity being dirty), so it saves to theme-A and thus theme-B is still dirty and the save looks like it didnt take.

Addison-Stavlo commented 3 years ago

I think I found the problem. More explanation on https://github.com/WordPress/gutenberg/pull/29842 - but it seems there are a few things going on making this flow problematic.

Addison-Stavlo commented 3 years ago

should be fixed now with https://github.com/WordPress/gutenberg/pull/29842