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

This commit is contained in:
Shamim Rezaie 2024-11-26 20:59:43 +11:00
commit 35b9ad6bbf
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

View File

@ -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);