From 6019c0108842a8b2c798620e7b2ce66c5631cf79 Mon Sep 17 00:00:00 2001 From: JackSteele24 Date: Wed, 24 Apr 2024 15:17:18 -0400 Subject: [PATCH] feat: Preventing the entire page from scrolling when sidebar auto-scrolls --- .../course/sidebar/sidebars/outline/OutlineSidebar.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/courseware/course/sidebar/sidebars/outline/OutlineSidebar.jsx b/src/courseware/course/sidebar/sidebars/outline/OutlineSidebar.jsx index ee0660c514..304fef863f 100644 --- a/src/courseware/course/sidebar/sidebars/outline/OutlineSidebar.jsx +++ b/src/courseware/course/sidebar/sidebars/outline/OutlineSidebar.jsx @@ -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 (