Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: redirect after esc button in any setting page (#193)
Browse files Browse the repository at this point in the history
* Fix the redirect after exc button in any setting page

* handle esc only on opened modals

* code styling change

Co-authored-by: nina992 <nouralali992@gmail.com>
  • Loading branch information
nina992 and nina992 authored Apr 13, 2022
1 parent a90dda4 commit c8ec354
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/atoms/Modal/ModalFrame/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const Modal: React.FC<Props> = ({ size, isVisible, onClose, children }) => {
unmountOnExit: true,
});

const handleClose = useCallback(() => onClose?.(), [onClose]);
const handleClose = useCallback(() => {
if (isVisible) onClose?.();
}, [onClose, isVisible]);

useKeyPressEvent("Escape", handleClose);

Expand Down

0 comments on commit c8ec354

Please sign in to comment.