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

Navigation and Mini Cart blocks conflict #35768

Closed
grogou opened this issue Oct 19, 2021 · 8 comments · Fixed by #37135
Closed

Navigation and Mini Cart blocks conflict #35768

grogou opened this issue Oct 19, 2021 · 8 comments · Fixed by #37135
Assignees
Labels
[Block] Navigation Affects the Navigation Block Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.

Comments

@grogou
Copy link

grogou commented Oct 19, 2021

Description

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

image
this and mini cart is not working.

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.

Step-by-step reproduction instructions

  1. Create some page
  2. Insert Navigation and Mini cart blocks and save
  3. Open the page and check that last block in order is not working

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

@carolinan
Copy link
Contributor

carolinan commented Oct 22, 2021

Mini cart is not a WordPress core or Gutenberg block, so you would need to contact the developer of that block.
This conflict can not be tested, as we need more information about the custom block.

@carolinan carolinan added [Block] Navigation Affects the Navigation Block [Status] Needs More Info Follow-up required in order to be actionable. labels Oct 22, 2021
@talldan talldan added [Type] Bug An existing feature does not function as intended [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes. and removed [Status] Needs More Info Follow-up required in order to be actionable. labels Oct 22, 2021
@talldan
Copy link
Contributor

talldan commented Oct 22, 2021

Seems like a legit issue. This is where the nav block is overriding onload:

window.onload = () =>
MicroModal.init( {
onShow: navigationToggleModal,
onClose: navigationToggleModal,
openClass: 'is-menu-open',
} );

It could as you say use addEventListener or keep a ref to the previous onload and make sure it triggers it.

@talldan talldan added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Oct 22, 2021
@carolinan
Copy link
Contributor

carolinan commented Oct 22, 2021

I wasn't trying to say that it was not a legit issue, but that more information about which "mini cart" block is used.
Without that the reproduction instructions can't be followed.

Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes

@talldan
Copy link
Contributor

talldan commented Oct 22, 2021

I didn't say you weren't trying to say it wasn't a legit issue 😄

You're right, better testing instructions would be good 👍

Does look like a fairly easy code quality issue to fix that'll help the nav block to play nicely with plugins.

@grogou
Copy link
Author

grogou commented Oct 22, 2021

I wasn't trying to say that it was not a legit issue, but that more information about which "mini cart" block is used. Without that the reproduction instructions can't be followed.

Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes

Sorry @carolinan I will give you more information next time. Thank you.

@grogou
Copy link
Author

grogou commented Oct 22, 2021

It is something easy case so I didn't think we need something more explanation.

@grogou
Copy link
Author

grogou commented Oct 22, 2021

Mini cart is not a WordPress core or Gutenberg block, so you would need to contact the developer of that block. This conflict can not be tested, as we need more information about the custom block.

Mini Cart is Woocommerce block, so I will remember it is not recognized block for Gutenberg.

@carolinan
Copy link
Contributor

That's what I figured, but there is more than one with that name 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants