Skip to content

Commit

Permalink
fix(modal): wait modal action
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmen committed Oct 21, 2023
1 parent 9062f97 commit 80e899e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/modals/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ export const Modal: FC<ModalProps> = ({title, text, actions, onClose}) => {
<Content>
{text}
</Content>
{actions && <ActionContent onClick={() => onClose()}>
{actions.map(({text, onClick,...props}) => <Button key={text}
onClick={e => {
e.preventDefault();
return onClick?.(e);
}} {...props}>{text}</Button>)}
{actions && <ActionContent>
{actions.map(({text, onClick, ...props}) =>
<Button
key={text}
onClick={async e => {
e.preventDefault();
await onClick?.(e);
onClose();
}} {...props}>{text}</Button>)}
</ActionContent>}
</Wrapper>;
};
Expand Down

0 comments on commit 80e899e

Please sign in to comment.