Skip to content

Commit fbe0f03

Browse files
authored
docs: fix left-hand sidebar scrolling issue (#33796)
1 parent 95dcb27 commit fbe0f03

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

doc/user/assets/sass/_layout.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ table.inline-headings {
139139
z-index: 100;
140140
top: var(--nav-height);
141141
left: 0;
142+
height: calc(100vh - var(--nav-height));
142143
border-right: 1px solid var(--divider-light);
143144
transform: translateX(-100%);
144145
transition: all .2s ease-out;
@@ -167,10 +168,11 @@ table.inline-headings {
167168
top: var(--nav-height);
168169
padding: var(--xx-small) var(--small);
169170
overflow-y: auto;
170-
height: 100vh;
171+
height: calc(100vh - var(--nav-height));
171172
display: flex;
172173
font-size: rem(1.3);
173174
overflow-x: hidden;
175+
overscroll-behavior: contain;
174176

175177
&,
176178
ul {
@@ -190,6 +192,7 @@ table.inline-headings {
190192

191193
@media(max-width: 850px) {
192194
padding-bottom: var(--large);
195+
height: calc(100vh - var(--nav-height));
193196
}
194197

195198
a {

doc/user/layouts/_default/baseof.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,58 @@
197197
closeSidebar();
198198
});
199199

200+
// Prevent body scroll when scrolling in sidebar
201+
const sidebar = document.querySelector(".sidebar");
202+
let isScrollingSidebar = false;
203+
204+
sidebar.addEventListener("wheel", (e) => {
205+
const sidebarElement = e.currentTarget;
206+
const { scrollTop, scrollHeight, clientHeight } = sidebarElement;
207+
208+
// Check if we're at the top or bottom of the sidebar
209+
const isAtTop = scrollTop === 0;
210+
const isAtBottom = scrollTop + clientHeight >= scrollHeight - 1; // Small tolerance for rounding
211+
212+
// If scrolling up and at top, or scrolling down and at bottom, prevent default
213+
if ((e.deltaY < 0 && isAtTop) || (e.deltaY > 0 && isAtBottom)) {
214+
e.preventDefault();
215+
}
216+
}, { passive: false });
217+
218+
// Also handle touch events for mobile
219+
sidebar.addEventListener("touchstart", () => {
220+
isScrollingSidebar = true;
221+
});
222+
223+
sidebar.addEventListener("touchend", () => {
224+
isScrollingSidebar = false;
225+
});
226+
227+
// Prevent body scroll when actively scrolling sidebar
228+
document.addEventListener("wheel", (e) => {
229+
if (isScrollingSidebar) {
230+
e.preventDefault();
231+
}
232+
}, { passive: false });
233+
234+
// Ensure sidebar content is properly scrollable when expanded
235+
const ensureSidebarScrollability = () => {
236+
const sidebar = document.querySelector(".sidebar");
237+
if (sidebar) {
238+
// Force a reflow to ensure proper height calculation
239+
sidebar.style.height = 'auto';
240+
sidebar.offsetHeight; // Trigger reflow
241+
sidebar.style.height = '';
242+
}
243+
};
244+
245+
// Run on menu expansion
246+
document.addEventListener('click', (e) => {
247+
if (e.target.closest('.sidebar a') && e.target.closest('li').classList.contains('has-children')) {
248+
setTimeout(ensureSidebarScrollability, 100);
249+
}
250+
});
251+
200252
backdrop.addEventListener("click", () => {
201253
closeSidebar();
202254
});

0 commit comments

Comments
 (0)