From 8c1e8c49eb1ab0effca02001abaaa8f33898f7f9 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 23 Sep 2024 09:46:47 +0200 Subject: [PATCH] fix: conditionally hide sections in edit mode only Wrapped the logic to hide sections in an edit mode check, ensuring it only runs when the page is in edit mode. This prevents unintended hiding of sections during normal view, improving the user experience. --- script.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/script.js b/script.js index 5efa2db..6beb22d 100644 --- a/script.js +++ b/script.js @@ -212,18 +212,22 @@ ); }); - var sections = $('.course-section'); - var found = false; + const editMode = $(".inplaceeditable").length > 0; - sections.each(function (index) { - if (!found && $(this).find('script[data-activity-id]').length > 0) { - // Set found to true when the first matching section is found - found = true; - } else if (found) { - // Hide all .section elements after the found one - $(this).css('visibility', 'hidden'); - } - }); + if (editMode) { + var sections = $('.course-section'); + var found = false; + + sections.each(function (index) { + if (!found && $(this).find('script[data-activity-id]').length > 0) { + // Set found to true when the first matching section is found + found = true; + } else if (found) { + // Hide all .section elements after the found one + $(this).css('visibility', 'hidden'); + } + }); + } }) }) .catch((error) => {