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

WC navigation handler clears current class from every element on entire page. #7772

Closed
tomalec opened this issue Oct 8, 2021 · 0 comments · Fixed by #7773
Closed

WC navigation handler clears current class from every element on entire page. #7772

tomalec opened this issue Oct 8, 2021 · 0 comments · Fixed by #7773
Labels
focus: navigation type: bug The issue is a confirmed bug.

Comments

@tomalec
Copy link
Member

tomalec commented Oct 8, 2021

Describe the bug

In Google Listings & Ads plugin, we use some sub-navigation in a number of places and use NavigableMenu, Link elements, and current CSS class for consistency with the rest of WC UI.

It occurred that sometimes the "current"/"active" state of an element was cleared in what seemed to be unrelated navigation events.

It occurred that wpNavMenuClassChange function, used (as the name suggests) to change class on WP navigation menu, changes the current class one every element on the page. Including our components and sub-navigation.

To Reproduce

  1. Create your own instance of a component & HTML element with current class.
  2. Use WC's Link element to internally (SPA) navigate to some other page that still has the above element rendered / Call window.wpNavMenuClassChange( {wpOpenMenu: 'toplevel_page_woocommerce-marketing'}, window.location.href )
  3. Check the class attribute of the HTML element.

Actual behavior:

The current class is removed from our element.

Screenshots

class current

curr navigation

Expected behavior

Elements outside the WP menu should not be affected by wpNavMenuClassChange and WC-admin navigation.

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser Chrome, Firefox

Additional context

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: navigation type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant