Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Mini Cart and Navigation blocks conflict #4952

Closed
grogou opened this issue Oct 15, 2021 · 6 comments · Fixed by #5051
Closed

Mini Cart and Navigation blocks conflict #4952

grogou opened this issue Oct 15, 2021 · 6 comments · Fixed by #5051
Assignees
Labels
block: mini-cart Issues related to the Mini-Cart block. focus: FSE Work related to prepare WooCommerce for FSE. type: bug The issue/PR concerns a confirmed bug. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team.

Comments

@grogou
Copy link
Contributor

grogou commented Oct 15, 2021

Describe the bug

The Mini Cart and Navigation blocks are using window.onload event, first for lazy load scripts, second one for init some MicroModal. So if I use these blocks on same page, only work the second rendered block action. In my case I have

After some research.

I replaced window.onload to window.addEventListener('load',function(){})
Using this method ensures that the handler is additive and does not replace existing handlers.
And the 2 blocks works properly.

Screenshots

image
this and mini cart is not working.

Testing steps

  1. Make sure you have Gutenberg and Woo Blocks plugins installed
  2. Create a new page and add the Mini cart block first
  3. Save the page and go to the site to see the Mini cart block working
  4. Go back and add the Navigation block after the mini cart
  5. Save the page and go to the front-end to see the page
  6. Notice that the Mini Cart block stopped working.

Expected behaviour

The Mini cart block should work.

@grogou grogou added the type: bug The issue/PR concerns a confirmed bug. label Oct 15, 2021
@Aljullu Aljullu added focus: FSE Work related to prepare WooCommerce for FSE. block: mini-cart Issues related to the Mini-Cart block. labels Oct 15, 2021
@Aljullu
Copy link
Contributor

Aljullu commented Oct 15, 2021

Good catch with this issue, @grogou!

I added this to the Mini Cart project so we can take a look at it and fix it. Thanks for letting us know!

I wonder if we should also create an issue in Gutenberg regarding this. Rewriting what is in window.onload might break some other plugins besides WC Blocks. What do you think?

@Aljullu Aljullu changed the title Mini Cart and Navigation blocks conflict. Mini Cart and Navigation blocks conflict Oct 15, 2021
@grogou
Copy link
Contributor Author

grogou commented Oct 15, 2021

@Aljullu I think we need to change it in both places, so if you need I can create same issue on Gutenberg too, because addEventListener more scalable. But the only thing I can't understand, why this case works clean on TT1 Blocks theme, it is strange.

@Aljullu
Copy link
Contributor

Aljullu commented Oct 18, 2021

Yes, I think it might be worth raising this issue in Gutenberg as well and see what they think about it. If you can create it, that would be perfect, thanks! 👌

@grogou
Copy link
Contributor Author

grogou commented Oct 22, 2021

@Aljullu we have answer from Gutenberg. WordPress/gutenberg#35768 . So they added this to Navigation block todo list.

@Aljullu
Copy link
Contributor

Aljullu commented Oct 23, 2021

Thanks for bringing that upstream @grogou!

@Aljullu Aljullu added the type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. label Oct 28, 2021
@ralucaStan
Copy link
Contributor

I have updated the issue description with Testing steps and Expected behaviour sections for better understanding.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: mini-cart Issues related to the Mini-Cart block. focus: FSE Work related to prepare WooCommerce for FSE. type: bug The issue/PR concerns a confirmed bug. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants