Skip to content

Commit bcaefcc

Browse files
authored
fix(Modal): call close when pressing Esc (#1374)
Signed-off-by: Kim Anh Nguyen <4783194+kimanhou@users.noreply.github.com>
1 parent c5311c3 commit bcaefcc

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/components/Modal/Modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ export const Modal = ({
124124
return listener && listener(event);
125125
};
126126

127-
document.addEventListener("keydown", keyDown);
127+
document.addEventListener("keydown", keyDown, true);
128128
return () => {
129-
document.removeEventListener("keydown", keyDown);
129+
document.removeEventListener("keydown", keyDown, true);
130130
};
131-
});
131+
}, [close]);
132132

133133
const handleContentOnMouseDown = () => {
134134
shouldClose.current = false;

0 commit comments

Comments
 (0)