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

Fix navigation not closing on large screens #7591

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion source/_static/js/myscript-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $(document).ready(function () {
}

// Listen for changes in the theme preference
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function (e) {
// Only update the theme based on prefers-color-scheme if 'data-theme' is 'auto' or not set
if (
!$('body').attr('data-theme') ||
Expand Down Expand Up @@ -149,4 +149,18 @@ $(document).ready(function () {
document.body.classList.toggle('nav-open');
document.getElementById('navigation').classList.toggle('nav-is-active');
});

// Remove classes to close the nav if screen size is larger than 992px
function closeNav() {
if (window.innerWidth > 992) {
document.body.classList.remove('nav-open');
document.getElementById('navigation').classList.remove('nav-is-active');
hamburger.classList.remove('is-active');
}
}

closeNav();

$(window).on('resize', closeNav);

});