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.
This commit is contained in:
Kumi 2024-09-23 09:46:47 +02:00
parent a1185aba77
commit 8c1e8c49eb
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -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) => {