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

Header template-part disappears from template after theme change #42181

Open
Tracked by #11648 ...
kmanijak opened this issue Oct 17, 2023 · 11 comments · May be fixed by #46831
Open
Tracked by #11648 ...

Header template-part disappears from template after theme change #42181

kmanijak opened this issue Oct 17, 2023 · 11 comments · May be fixed by #46831
Assignees
Labels
focus: template Issue related to WooCommerce templates. team: Kirigami & Origami type: bug The issue is a confirmed bug. type: compatibility

Comments

@kmanijak
Copy link
Contributor

kmanijak commented Oct 17, 2023

Description

The header template part disappears on the frontend after updating the theme, when used in other templates.

Steps to reproduce

  1. On TT3
  2. Go to Product Catalog template
  3. Make sure you have Header template-part included in the template
  4. Make ANY change to Header template-part and save it so it's customised
  5. Update to TT4
  6. Go to frontend (/shop)

Expected: Header is still there
Actual: Header is missing

Editor FE
image image

More details

When entering the code editor you can see the template part has a theme assigned:

<!-- wp:template-part {"slug":"header","theme":"twentytwentythree"} /-->

After updating the theme value manually in the code editor to twentytwentyfour it appears on the frontend

@kmanijak kmanijak added type: bug The issue is a confirmed bug. focus: template Issue related to WooCommerce templates. labels Oct 17, 2023
@nerrad nerrad added the priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. label Oct 27, 2023
@danieldudzic
Copy link
Contributor

I have tested this, but I'm unable to replicate the issue.

The new theme correctly loads its own Header template and the old template no longer is relevant (on my test site).

@danieldudzic
Copy link
Contributor

@sunyatasattva Are you able to replicate this? I'd appreciate it if you could have a look. 🙏

@sunyatasattva
Copy link
Contributor

Hey @danieldudzic and @kmanijak, I think I see what's the problem here. It seems like when you activate a theme you have a template part that belongs to that theme. If you then modify a template containing that template part, and then switch theme, the problem appears: probably because the theme doesn't want to override any user changes.

This is probably a bug in core, to be honest.

@danieldudzic
Copy link
Contributor

I don't think this is a bug. As you mentioned, a theme-related template part belongs to that theme. If the new theme provides its own template part, it should take priority over the customized one (from the previous theme).

@sunyatasattva
Copy link
Contributor

Mm, I think we are talking about two different things right now, perhaps I didn't express myself correctly. You say:

If the new theme provides its own template part, it should take priority over the customized one (from the previous theme).

That's exactly what is not happening. The new theme template part won't take priority over a customized one.

Also, I'm not sure I agree that it should, and this is a much more nuanced conversation than what's happening here, albeit very similar: what happens here is that if someone customized a template which includes a template part, and then changes a theme, that template part won't be updated, causing an error, as it's not available anymore.

This is why I think this is a bug. I hope I expressed myself correctly here.

@danieldudzic
Copy link
Contributor

I see what you are saying. Thank you for clarifying the situation for me. I was now able to replicate the issue.

I have tried replicating this with WooCommerce disabled but wasn't able to.

I was able to replicate it with 6.3.2 and TT3.

Do you have any idea where the bug could be originating from?

@kmanijak
Copy link
Contributor Author

kmanijak commented Nov 6, 2023

Thanks for adding more info! I added the Header customization as a necessary step in steps to reproduce.

I have tried replicating this with WooCommerce disabled but wasn't able to.

@danieldudzic, in such a case my guess would be BlockTemplatesController!

@Aljullu
Copy link
Contributor

Aljullu commented Nov 6, 2023

For me, in order to reproduce, I had to:

  1. On TT3
  2. Go to Product Catalog template
  3. Make sure you have Header template-part included in the template
  4. Make ANY change to Header template-part and save it so it's customised.
  5. Make also a change to the Product Catalog template and save it so it's customised.
  6. Update to TT4
  7. Go to frontend (/shop)

Not sure if it's only me, but without step 5 I couldn't reproduce. 😓


I also noticed a couple of things:

  1. The issue can be reproduced with other themes. So I would say it's not specific to Twenty-Twenty Four.
  2. The issue can't be reproduced with non-WooCommerce templates. That's because when modifying a non-WC template, those modifications are saved "attached" to the theme, so when switching to another theme, the default template is loaded instead of the modified one.

IMO the best solution would be to do the same with WooCommerce templates: so when modifying a WooCommerce template, it's saved "attached" to the theme and, when switching themes, the default template is loaded again. Switching back to the initial theme, should load the modified template. Does that sound like a good approach?

cc @gigitux @tjcafferkey as this seems related to the project to refactor of BlockTemplatesController.

@gigitux
Copy link
Contributor

gigitux commented Nov 7, 2023

@Aljullu Yes, this issue will be addressed with the project about BlockTemplatesController. @nielslange opened a similar issue woocommerce/woocommerce-blocks#11106.

I want to highlight that this is not a regression introduced by us in the last weeks or for some changes in WordPress 6.4.

I think that we have had this wrong behavior for a long time, so even if we must fix it, should we keep the label high priority?

@danieldudzic
Copy link
Contributor

danieldudzic commented Nov 7, 2023

I'm comfortable with removing the high priority label. This issue should probably also be moved from the 6.4 & TT4 epic to the BlockTemplatesController project.

@gigitux
Copy link
Contributor

gigitux commented Nov 7, 2023

I'm confortable with removing the high priority label. This issue should probably also be moved from the 6.4 & TT4 epic to the BlockTemplatesController project.

It makes sense! The issue has been added to #42251! Thanks, @tjcafferkey!

@ObliviousHarmony ObliviousHarmony transferred this issue from woocommerce/woocommerce-blocks Dec 11, 2023
@albarin albarin removed the priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. label Dec 13, 2023
@Aljullu Aljullu self-assigned this Apr 23, 2024
@Aljullu Aljullu linked a pull request Apr 23, 2024 that will close this issue
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: template Issue related to WooCommerce templates. team: Kirigami & Origami type: bug The issue is a confirmed bug. type: compatibility
Projects
Status: In progress
Status: In progress
Development

Successfully merging a pull request may close this issue.

7 participants