From 35c9c74d4fdceef09f4f6969f8075b01562a1354 Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Sat, 8 Aug 2026 01:53:27 +0200 Subject: [PATCH] fix: don't scroll the page when toggling anchor-driven widgets The widgets they drive should handle the click themselves. --- lms/templates/courseware/courseware-chromeless.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lms/templates/courseware/courseware-chromeless.html b/lms/templates/courseware/courseware-chromeless.html index deeda26c431d..1fb59f3bdcdc 100644 --- a/lms/templates/courseware/courseware-chromeless.html +++ b/lms/templates/courseware/courseware-chromeless.html @@ -138,6 +138,14 @@ // the href attribute is an id or name, the page will scroll the id or name. $('a').on("click", function(event){ if ($(this).attr('href')[0] === '#') { + // Anchors that operate a widget (like accordions, tabs, dropdowns) + // point at the region they control rather than navigating to it, and + // handle the click themselves. Scrolling that region to the top of + // the page jumps the surrounding learning MFE viewport every time the + // widget is toggled, so we can leave these anchors alone. + if (this.hasAttribute('aria-controls') || this.hasAttribute('data-toggle')) { + return; + } var targetId = $(this).attr('href'); // Checks if the href attribute is auto scrolling video transcripts. // The scroll behavior for transcript scrolling requires the viewport