1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-14 13:02:07 +02:00

Merge branch 'MDL-77957-main-test2' of https://github.com/rezaies/moodle

This commit is contained in:
Shamim Rezaie 2024-11-26 20:56:42 +11:00
commit 1132cfcf44
3 changed files with 12 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -778,7 +778,10 @@ const registerListeners = () => {
drawerMap.forEach(drawerInstance => {
disableDrawerTooltips(drawerInstance.drawerNode);
if (drawerInstance.isOpen) {
if (drawerInstance.closeOnResize) {
const currentFocus = document.activeElement;
const drawerContent = drawerInstance.drawerNode.querySelector(SELECTORS.DRAWERCONTENT);
const shouldClose = drawerInstance.closeOnResize && (!drawerContent || !drawerContent.contains(currentFocus));
if (shouldClose) {
drawerInstance.closeDrawer();
} else {
anyOpen = true;
@ -798,6 +801,12 @@ const registerListeners = () => {
};
document.addEventListener('scroll', () => {
const currentFocus = document.activeElement;
const drawerContentElements = document.querySelectorAll(SELECTORS.DRAWERCONTENT);
// Check if the current focus is within any drawer content.
if (Array.from(drawerContentElements).some(drawer => drawer.contains(currentFocus))) {
return;
}
const body = document.querySelector('body');
if (window.scrollY >= window.innerHeight) {
body.classList.add(CLASSES.SCROLLED);