fix(web): make ConfirmDialog Escape capture-phase to prevent leaking to ancestor modals

This commit is contained in:
Jannis Braun
2026-04-29 01:26:38 +02:00
parent bde4d829ef
commit 5b51980278
@@ -25,13 +25,16 @@ export function ConfirmDialog({
loading = false,
}: ConfirmDialogProps) {
const handleKeyDown = useCallback((e: KeyboardEvent) => {
if (e.key === 'Escape' && !loading) onClose();
if (e.key === 'Escape' && !loading) {
e.stopPropagation();
onClose();
}
}, [onClose, loading]);
useEffect(() => {
if (isOpen) {
document.addEventListener('keydown', handleKeyDown);
return () => document.removeEventListener('keydown', handleKeyDown);
document.addEventListener('keydown', handleKeyDown, true);
return () => document.removeEventListener('keydown', handleKeyDown, true);
}
}, [isOpen, handleKeyDown]);