mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
fix: filter dropdown now closable with escape, doesn't close whole modal
This commit is contained in:
parent
959e301f99
commit
df1765c48e
1 changed files with 17 additions and 1 deletions
|
|
@ -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);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue