Skip to content

Commit

Permalink
fix(core): cannot close peek-view by Escape
Browse files Browse the repository at this point in the history
  • Loading branch information
CatsJuice committed Jul 3, 2024
1 parent 2ce1c34 commit bc66552
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ export const PeekViewModalContainer = forwardRef<
});
}, []);

useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
onOpenChange(false);
}
};
document.addEventListener('keydown', onKeyDown);
return () => {
document.removeEventListener('keydown', onKeyDown);
};
}, [onOpenChange]);

useEffect(() => {
if (animation === 'zoom') {
open ? animateZoomIn() : animateZoomOut();
Expand Down

0 comments on commit bc66552

Please sign in to comment.