Skip to content

Commit

Permalink
move on close to props
Browse files Browse the repository at this point in the history
  • Loading branch information
hiba9201 committed Dec 10, 2023
1 parent f1b2787 commit da6a22e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions client/components/UI/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ export function Modal({ title = null, children, onClose = () => {} }) {
ref.current.showModal();
// Remove focus after open
(document.activeElement as HTMLElement).blur();

ref.current.addEventListener('close', onClose);

return () => ref.current?.removeEventListener('close', onClose);
}, []);

const close = () => {
ref.current.close();
};

return (
<dialog className={cn(styles.Modal)} ref={ref}>
<dialog className={cn(styles.Modal)} ref={ref} onClose={onClose}>
<button className={cn(styles.ModalClose)} onClick={close}>
<Close />
</button>
Expand Down

1 comment on commit da6a22e

@ekbdev
Copy link

@ekbdev ekbdev commented on da6a22e Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for transport ready!

✅ Preview
https://transport-ijonqro0n-ekbdev.vercel.app
https://ekbdev-transport-feat-article-modals.vercel.app

Built with commit da6a22e.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.