Skip to content

RWD: removed useless code #3207

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

Closed
wants to merge 1 commit into from
Closed

RWD: removed useless code #3207

wants to merge 1 commit into from

Conversation

fballiano
Copy link

If I'm not mistaken this code doesn't precisely nothing:

    enquire.register('screen and (min-width: ' + (bp.medium + 1) + 'px)', {
        match: function () {
            $j('.menu-active').removeClass('menu-active');
            $j('.sub-menu-active').removeClass('sub-menu-active');
            $j('.skip-active').removeClass('skip-active');
        },
        unmatch: function () {
            $j('.menu-active').removeClass('menu-active');
            $j('.sub-menu-active').removeClass('sub-menu-active');
            $j('.skip-active').removeClass('skip-active');
        }
    });

since the match and unmatch code is exactly the same.

This PR removed this part of code.

@justinbeaty
Copy link
Contributor

Away from my computer now. But I think it is used to close any active menus when switching screen sizes. IIRC, Magento duplicated some menu structure for mobile and regular sizes, so it could have been used to fix a glitch where the menu is stuck open.

Perhaps try opening the mini cart or user menu and switch screen size to see if you encounter a bug.

@justinbeaty
Copy link
Contributor

So it's not as bad as I remember, but there are bugs caused by the removal of that code.

To reproduce, go to mobile viewport and open the menu (category navigation). Then resize the viewport to non-mobile:

image

On non-mobile, header-nav and header-search should never act as skip-links like the user menu and minicart. But, on mobile they do, so when resizing without the enquire code, the skip-active class isn't removed and you'll see the grey background on the navigation element.

It's not super buggy, but I recall having done some customizations on an old site where not resetting the menus on viewport change caused more problems. So, I'd probably leave this code in, but in #3208 it could be made more clear, such as:

resetMenuState = function (mq) {
  $j('.menu-active').removeClass('menu-active');
  $j('.sub-menu-active').removeClass('sub-menu-active');
  $j('.skip-active').removeClass('skip-active');
}
maxWidthMediumMediaQuery.addEventListener('change', resetMenuState );

@fballiano
Copy link
Author

thanks a lot @justinbeaty, this PR has to be closed, I'll fix the other one tho ;-)

@fballiano fballiano closed this Apr 22, 2023
@fballiano fballiano deleted the rwd_useless_code branch April 22, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Template : rwd Relates to rwd template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants