mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
Merge d4327173c7 into 5bfebc7c9d
This commit is contained in:
commit
be7d21703e
1 changed files with 10 additions and 15 deletions
|
|
@ -78,29 +78,24 @@ 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(
|
||||
(event: KeyboardEvent) => {
|
||||
const tooltips = document.querySelectorAll('.tooltip');
|
||||
const dropdownMenus = document.querySelectorAll('[role="menu"]');
|
||||
|
||||
for (const tooltip of Array.from(tooltips)) {
|
||||
const computedStyle = window.getComputedStyle(tooltip);
|
||||
const opacity = parseFloat(computedStyle.opacity);
|
||||
|
||||
if (
|
||||
tooltip.parentElement &&
|
||||
computedStyle.display !== 'none' &&
|
||||
computedStyle.visibility !== 'hidden' &&
|
||||
opacity > 0
|
||||
) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (tooltips.length > 0) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (dropdownMenus.length > 0) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Call the original handler if it exists
|
||||
propsOnEscapeKeyDown?.(event);
|
||||
},
|
||||
[propsOnEscapeKeyDown],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue