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

problem with active menu item #397

Open
benthien opened this issue Apr 8, 2019 · 12 comments
Open

problem with active menu item #397

benthien opened this issue Apr 8, 2019 · 12 comments
Assignees

Comments

@benthien
Copy link

benthien commented Apr 8, 2019

I inserted code in header.php that produces a top bar for medium and higher and an offcanvas menu for small devices. It works fine except the active menu item is not highlighted. I put class="active" on the menu item and made the following changes in _settings.scss

$dropdown-menu-item-color-active: $white;
$dropdown-menu-item-background-active: get-color(primary);

I made similar changes for the offcanvas menu and that works fine.

@garretthyder
Copy link
Collaborator

Hi @benthien are you putting the active class on the li or the a element as I believe it should be on the li. Hope it's that simple otherwise will delve deeper. Cheers

@benthien
Copy link
Author

benthien commented Apr 9, 2019 via email

@garretthyder
Copy link
Collaborator

Thanks for confirming @benthien moving the active class to the li element should resolve your issue. Let us know if you have any other issues. Cheers

@benthien
Copy link
Author

benthien commented Apr 9, 2019 via email

@garretthyder
Copy link
Collaborator

Hi @benthien if your active class is on the link move it to it's parent

  • . The Foundation CSS expects it on the
  • and not the link element. Hope that clarifies.

  • @benthien
    Copy link
    Author

    benthien commented Apr 9, 2019 via email

    @garretthyder
    Copy link
    Collaborator

    Thanks @benthien looking at my site the .active css chain is .menu .active > a. So the .active class is on the li but there's also a .menu class on the ul. Is the menu class present in your build? Cheers

    @benthien
    Copy link
    Author

    benthien commented Apr 10, 2019 via email

    @garretthyder
    Copy link
    Collaborator

    Thanks @benthien that's definitely odd, your markup looks right.
    After you made the scss change did you npm run build to compile the SCSS to CSS?
    Also when you inspect the active element that should be highlighted (inspect the .active > a element) is there any CSS for the .active class on the element?

    @benthien
    Copy link
    Author

    benthien commented Apr 13, 2019 via email

    garretthyder pushed a commit that referenced this issue Apr 14, 2019
    …6.4.0 onwards
    
    This addresses issues found in #397 where the $dropdown-menu-item-background-active didn't seem to apply. But the actual issue is Foundation now uses .is-active and not .active.
    
    To preserve back-compat for other devs I've left .active present.
    @garretthyder
    Copy link
    Collaborator

    Thanks for that @benthien testing on a clean install I was able to reproduce your issue and found there's actually a JointsWP issue in place right now.

    It seems in Foundation 6.4.0 the active class was renamed is-active but active was still supported;
    "Menus now use is-active instead if active for active state. The old active works but is deprecated and will be removed."
    Release Notes - https://github.com/zurb/foundation-sites/releases/tag/v6.4.0

    The current foundation docs support this;
    "Add the class .is-active to any

  • to create an active state. You could apply this server-side to mark the active page, or dynamically with JavaScript."
    https://foundation.zurb.com/sites/docs/menu.html#active-state

    In JointsWP it seems we're still applying 'active' instead of 'is-active';
    https://github.com/JeremyEnglert/JointsWP/blob/master/functions/menu.php#L84-L91

    I've updated this with back-compat in mind by leaving the 'active' class and simply introducing the 'is-active' class as well.

    Give it a try and let me know if that helps with your styling.

    @JeremyEnglert can you take a look as well my PR is in Introduce .is-active to the active nav class as used from Foundation … #398.

    Thanks

  • @garretthyder garretthyder reopened this Apr 14, 2019
    @benthien
    Copy link
    Author

    benthien commented Apr 16, 2019 via email

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants