Skip to content

Commit

Permalink
Fix for info modals not closing when the X button is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelleher committed May 11, 2023
1 parent 127d864 commit 517dc3b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/app/src/common/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ const Button: React.FC<ButtonProps> = ({
<InfoModal
title={disabledTitle}
message={disabledMessage}
ok={infoModal.onModalOK}
show={infoModal.modalShown}
modalControl={infoModal}
/>
{children}
</button>
Expand Down
18 changes: 14 additions & 4 deletions packages/app/src/common/components/modals/InfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ import { Dialog } from "@headlessui/react";
import { ExclamationTriangleIcon } from "@heroicons/react/24/solid";
import React, { type FC, type PropsWithChildren } from "react";

import { BaseModal, type ModalProps } from "./";
import { BaseModal } from "./";
import { type ModalControl } from "../../hooks";

type InfoModalProps = { title: string; message?: string } & PropsWithChildren &
Omit<ModalProps, "cancel">;
type InfoModalProps = {
title: string;
message?: string;
modalControl: ModalControl;
} & PropsWithChildren;
const InfoModal: FC<InfoModalProps> = (props) => {
return (
<BaseModal cancelVisible={false} {...props} cancel={() => {}}>
<BaseModal
cancelVisible={false}
{...props}
ok={props.modalControl.onModalOK}
cancel={props.modalControl.onModalClose}
show={props.modalControl.modalShown}
>
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full">
<ExclamationTriangleIcon
className="w-8"
Expand Down

0 comments on commit 517dc3b

Please sign in to comment.