Skip to content

Commit ba8c573

Browse files
authored
Ensure body is scrollable if sidenav is dismissed (#11660)
Fixes the body not being scrollable if you have a narrow window, open the menu, then keep the menu open and make your window wide (causing it to close).
1 parent 373566f commit ba8c573

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/_sass/components/_sidebar.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ $sidenav-divider-color: #e7e8ed;
1515
display: none;
1616
width: 100%;
1717
z-index: 1010;
18+
background-color: $site-color-white;
1819

1920
@at-root body.open_menu {
2021
overflow-y: hidden;
2122

23+
@media (min-width: 1024px) {
24+
overflow-y: auto;
25+
}
26+
2227
#sidenav {
2328
display: block;
24-
background-color: $site-color-white;
2529
}
2630
}
2731

@@ -33,6 +37,7 @@ $sidenav-divider-color: #e7e8ed;
3337
top: calc($site-header-height);
3438
overscroll-behavior: auto;
3539
width: 16rem;
40+
background: none;
3641
}
3742

3843
.nav-header {

src/content/assets/js/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ function setupSidenavInteractivity() {
1717
document.body.classList.toggle('open_menu');
1818
});
1919

20+
window.addEventListener('resize', function() {
21+
if (window.innerWidth >= 1024) {
22+
document.body.classList.remove('open_menu');
23+
}
24+
});
25+
2026
document.addEventListener('keydown', function(event) {
2127
if (event.key === 'Escape') {
2228
const activeElement = document.activeElement;

0 commit comments

Comments
 (0)