fix: filter dropdown now closable with escape, doesn't close whole modal

This commit is contained in:
Dustin Healy 2025-12-12 14:45:00 -08:00
parent 959e301f99
commit df1765c48e

View file

@ -78,7 +78,7 @@ const DialogContent = React.forwardRef<
},
ref,
) => {
/* Handle Escape key to prevent closing dialog if a tooltip is open
/* Handle Escape key to prevent closing dialog if a tooltip or dropdown is open
(this is a workaround in order to achieve WCAG compliance which requires
that our tooltips be dismissable with Escape key) */
const handleEscapeKeyDown = React.useCallback(
@ -100,6 +100,22 @@ const DialogContent = React.forwardRef<
}
}
// Check if a dropdown menu is open
const dropdownMenus = document.querySelectorAll('[role="menu"]');
for (const dropdown of Array.from(dropdownMenus)) {
const computedStyle = window.getComputedStyle(dropdown);
const opacity = parseFloat(computedStyle.opacity);
if (
computedStyle.display !== 'none' &&
computedStyle.visibility !== 'hidden' &&
opacity > 0
) {
event.preventDefault();
return;
}
}
// Call the original handler if it exists
propsOnEscapeKeyDown?.(event);
},