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, loading = false,
}: ConfirmDialogProps) { }: ConfirmDialogProps) {
const handleKeyDown = useCallback((e: KeyboardEvent) => { const handleKeyDown = useCallback((e: KeyboardEvent) => {
if (e.key === 'Escape' && !loading) onClose(); if (e.key === 'Escape' && !loading) {
e.stopPropagation();
onClose();
}
}, [onClose, loading]); }, [onClose, loading]);
useEffect(() => { useEffect(() => {
if (isOpen) { if (isOpen) {
document.addEventListener('keydown', handleKeyDown); document.addEventListener('keydown', handleKeyDown, true);
return () => document.removeEventListener('keydown', handleKeyDown); return () => document.removeEventListener('keydown', handleKeyDown, true);
} }
}, [isOpen, handleKeyDown]); }, [isOpen, handleKeyDown]);