Skip to content

Commit

Permalink
feat: Preventing the entire page from scrolling when sidebar auto-scr…
Browse files Browse the repository at this point in the history
…olls
  • Loading branch information
JackSteele24 authored and becdavid committed Jun 18, 2024
1 parent fbb062f commit 6019c01
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ function OutlineSidebar({
unitId,
} = useContext(SidebarContext);
const outlineUrl = `${getConfig().SIDEBAR_MFE_BASE_URL}/${courseId}/${unitId}`;
const savedScrollPosition = window.scrollY;
let allowScroll = true;
window.addEventListener('scroll', () => {
if (allowScroll) {
window.scrollTo(0, savedScrollPosition);
}
allowScroll = false;
});

return (
<SidebarBase
title={intl.formatMessage(messages.outlineTitle)}
Expand Down

0 comments on commit 6019c01

Please sign in to comment.