mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50: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,
|
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
|
(this is a workaround in order to achieve WCAG compliance which requires
|
||||||
that our tooltips be dismissable with Escape key) */
|
that our tooltips be dismissable with Escape key) */
|
||||||
const handleEscapeKeyDown = React.useCallback(
|
const handleEscapeKeyDown = React.useCallback(
|
||||||
(event: KeyboardEvent) => {
|
(event: KeyboardEvent) => {
|
||||||
const tooltips = document.querySelectorAll('.tooltip');
|
const tooltips = document.querySelectorAll('.tooltip');
|
||||||
|
const dropdownMenus = document.querySelectorAll('[role="menu"]');
|
||||||
|
|
||||||
for (const tooltip of Array.from(tooltips)) {
|
if (tooltips.length > 0) {
|
||||||
const computedStyle = window.getComputedStyle(tooltip);
|
event.preventDefault();
|
||||||
const opacity = parseFloat(computedStyle.opacity);
|
return;
|
||||||
|
}
|
||||||
if (
|
|
||||||
tooltip.parentElement &&
|
if (dropdownMenus.length > 0) {
|
||||||
computedStyle.display !== 'none' &&
|
event.preventDefault();
|
||||||
computedStyle.visibility !== 'hidden' &&
|
return;
|
||||||
opacity > 0
|
|
||||||
) {
|
|
||||||
event.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the original handler if it exists
|
|
||||||
propsOnEscapeKeyDown?.(event);
|
propsOnEscapeKeyDown?.(event);
|
||||||
},
|
},
|
||||||
[propsOnEscapeKeyDown],
|
[propsOnEscapeKeyDown],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue