gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

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

Open Sandstromer opened this issue 5 years ago • 10 comments

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

  • WordPress version: 5.6.1
  • Gutenberg version: 9.9.2
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes and No. TT1 Blocks and Q

Device information

  • Device: Desktop
  • Operating system: Win 10
  • Browser: Firefox

Sandstromer avatar Feb 11 '21 15:02 Sandstromer

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

Sandstromer avatar Feb 13 '21 10:02 Sandstromer

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.

paaljoachim avatar Feb 13 '21 10:02 paaljoachim

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

Sandstromer avatar Feb 13 '21 11:02 Sandstromer

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

paaljoachim avatar Feb 13 '21 19:02 paaljoachim

I can confirm that I am able to reproduce this.

carolinan avatar Feb 23 '21 09:02 carolinan

Confirming that I can replicate this as well.

annezazu avatar Feb 25 '21 23:02 annezazu

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

carolinan avatar Mar 12 '21 04:03 carolinan

That is super funky! I can repro as well:

  • Theme A - load site editor, edit header template part, and save
  • Switch to theme B - load site editor, edit header template part, and save does not take.
  • Switch back to theme A - load site editor, notice theme B's header template part is being used. 😕

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 avatar Mar 12 '21 19:03 Addison-Stavlo

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 avatar Mar 12 '21 21:03 Addison-Stavlo

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

Addison-Stavlo avatar Mar 24 '21 16:03 Addison-Stavlo