Skip to content

Commit

Permalink
feat: close modal on esc
Browse files Browse the repository at this point in the history
  • Loading branch information
simodrws committed Jul 28, 2023
1 parent cdf4710 commit 9a1cd41
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/refactor/ui/components/modals/modal.tsx
@@ -1,4 +1,4 @@
import React, { ReactNode, useCallback } from 'react';
import React, { ReactNode, useCallback, useRef } from 'react';
import Rodal from 'rodal';
import { useModal } from '@ebay/nice-modal-react';

Expand All @@ -10,21 +10,22 @@ export const Modal = ({
onClose?: () => unknown;
}) => {
const modal = useModal();
const modalRef = useRef(null);
const handleClose = useCallback(async () => {
onClose?.();
// await modal.hide();
console.log('closed modal');
await modal.hide();
}, [modal, onClose]);

return (
<Rodal
closeOnEsc
className="masa-rodal-container"
visible={modal.visible}
onClose={handleClose}
width={550}
height={615}
>
<div className="masa-modal">
<div ref={modalRef} className="masa-modal">
<div className="masa-modal-container">{children}</div>
</div>
</Rodal>
Expand Down

0 comments on commit 9a1cd41

Please sign in to comment.