Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TD-2946 Scene Freezes On Deleting Scenario #1012

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/ConfirmProvider/ConfirmProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,6 @@ describe("useConfirm", () => {
expect(queryByText("Arbitrary content")).toBeTruthy();
});

test("keeps custom text during close", () => {
const { getByText, queryByText } = render(
<TestComponent
confirmOptions={{
title: "Remove this item?"
}}
/>
);
fireEvent.click(getByText("Delete"));
expect(queryByText("Remove this item?")).toBeTruthy();
fireEvent.click(getByText("Yes"));
expect(queryByText("Remove this item?")).toBeTruthy();
});

test("honours default options passed to the provider", () => {
const { getByText, queryByText } = render(
<ConfirmProvider
Expand Down
106 changes: 55 additions & 51 deletions src/ConfirmProvider/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,58 +52,62 @@ const ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({
);

return (
<Dialog
fullWidth
{...dialogProps}
open={open}
onClose={onClose}
data-testid="confirm-dialog"
>
{title && (
// use the dialog title from the dialog title component
<DialogTitle onClose={onCancel} {...titleProps}>
{title}
</DialogTitle>
)}
<Divider />
{content ? (
<DialogContent sx={{ p: 2 }}>
<DialogContentText
sx={{
color: theme =>
theme.palette.mode === "light"
? "rgba(0, 0, 0, 0.8)"
: "rgba(255,255,255, 1)"
}}
<>
{open ? (
<Dialog
fullWidth
{...dialogProps}
open={true}
onClose={onClose}
data-testid="confirm-dialog"
>
{title && (
// use the dialog title from the dialog title component
<DialogTitle onClose={onCancel} {...titleProps}>
{title}
</DialogTitle>
)}
<Divider />
{content ? (
<DialogContent sx={{ p: 2 }}>
<DialogContentText
sx={{
color: theme =>
theme.palette.mode === "light"
? "rgba(0, 0, 0, 0.8)"
: "rgba(255,255,255, 1)"
}}
>
{content}
<DialogContentText />
</DialogContentText>
</DialogContent>
) : (
description && (
<DialogContent sx={{ p: 2 }}>
<DialogContentText
sx={{
color: theme =>
theme.palette.mode === "light"
? "rgba(0, 0, 0, 0.8)"
: "rgba(255,255,255, 1)"
}}
>
{description}
</DialogContentText>
</DialogContent>
)
)}
<Divider />
<DialogActions
sx={{ justifyContent: "flex-end", padding: "16px" }}
{...dialogActionsProps}
>
{content}
<DialogContentText />
</DialogContentText>
</DialogContent>
) : (
description && (
<DialogContent sx={{ p: 2 }}>
<DialogContentText
sx={{
color: theme =>
theme.palette.mode === "light"
? "rgba(0, 0, 0, 0.8)"
: "rgba(255,255,255, 1)"
}}
>
{description}
</DialogContentText>
</DialogContent>
)
)}
<Divider />
<DialogActions
sx={{ justifyContent: "flex-end", padding: "16px" }}
{...dialogActionsProps}
>
{dialogActions}
</DialogActions>
</Dialog>
{dialogActions}
</DialogActions>
</Dialog>
) : null}
</>
);
};

Expand Down
Loading