-
Notifications
You must be signed in to change notification settings - Fork 21
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
Separate legacy WC menu handling to a separate hook, #1038
Conversation
from `<MainTabNav>`. Simplify it to use `window.wpNavMenuClassChange` instead of custom CSS selectors hacking. Use it in `Settings` sub-pages. Addresses part of #1037.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method looks good. But I have two questions:
- ❓ Although the active state of tabs already had a glitch (Report tabs lose active state when changing chart #621), the active state is completely disappeared in this PR.
- ❔ I wonder if the issue that WC menu highlight disappears after repeatedly clicking on the same tab could be fixed by this method as well?
I got the same effect on WP-admin re-renders the menu on the navigation even, and we have no hook to react on that. We could fix it my calling |
🤦♂️ This is a result of ignoring the scoping in WP functions window.wpNavMenuClassChange = function ( page, url ) {
Array.from( document.getElementsByClassName( 'current' ) ).forEach(
function ( item ) {
item.classList.remove( 'current' );
}
); it removes
|
Created an issue for 1. at woocommerce/woocommerce-admin#7772 |
I also fixed it in WC woocommerce/woocommerce-admin#7773 //cc @jconroy |
Looks like woocommerce/woocommerce-admin#7773 can fix both issues within the #1038 (review). 💯
Finally found out where the
Considering that 1) probably we still have a few months to wait for WC-admin to release the fixes and our L-2 version to be ready for bumping up, and 2) the cost looks small enough if we maintain a copy that has only 5 lines and has not been changed for 8 years. As a trade-off to exchange for fixing #621 early, I think it's okay. |
Good point. I duplicated the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing well. LGTM.
Tastes best with #1031
Changes proposed in this Pull Request:
Separate legacy WC menu handling to a separate hook, from
<MainTabNav>
.Simplify it to use
window.wpNavMenuClassChange
instead of custom CSS selectors hacking.Use it in
Settings
sub-pages.Addresses part of #1037.
After this change, any page can highlight the menu, even ones without
<MainTabNav>
Screenshots:
Before
After
Detailed test instructions:
/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsettings
/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsettings&subpath=%2Freconnect-accounts
`/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsettings%2Fedit-phone-number
/https://gla1.test/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsettings&subpath=%2Fedit-phone-number
Make sure the "Google Listings & Ads" is highlighted on the left menu.
Changelog entry
Additional notes