Skip to content

Commit

Permalink
🐛 ConfirmDeleteDialog: always clear name input value on action (#1479)
Browse files Browse the repository at this point in the history
`ConfirmDeleteDialog` requires the user to enter the item's name before
the delete button is enabled. The user entered text was being cleared on
Cancel and Close, but not on Confirm. Action handlers now clear the user
entered text on ALL actions.

Resolves: #1478

Signed-off-by: Scott J Dickerson <[email protected]>
Co-authored-by: Ian Bolton <[email protected]>
  • Loading branch information
sjd78 and ibolton336 authored Oct 17, 2023
1 parent 9096dcd commit 12d8166
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.confirm-deletion {
margin-top: var(--pf-v5-global--spacer--xl);
}

.confirm-deletion-input {
margin-top: var(--pf-v5-global--spacer--sm);
margin-bottom: var(--pf-v5-global--spacer--sm);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,21 @@ const ConfirmDeleteDialog: FC<ConfirmDeleteDialogProps> = ({
onClose();
};

const handleOnConfirmDelete = () => {
if (!isDisabled) {
setNameToDeleteInput("");
onConfirmDelete();
}
};

const confirmBtn = (
<Button
id="confirm-delete-dialog-button"
key="confirm"
aria-label="confirm"
variant={ButtonVariant.danger}
isDisabled={isDisabled}
onClick={isDisabled ? undefined : onConfirmDelete}
onClick={handleOnConfirmDelete}
>
{deleteBtnLabel ?? t("actions.delete")}
</Button>
Expand All @@ -70,6 +77,7 @@ const ConfirmDeleteDialog: FC<ConfirmDeleteDialogProps> = ({
{cancelBtnLabel ?? t("actions.cancel")}
</Button>
);

return (
<Modal
id="confirm-delete-dialog"
Expand All @@ -91,7 +99,7 @@ const ConfirmDeleteDialog: FC<ConfirmDeleteDialogProps> = ({
</Trans>
</Text>
<TextInput
className="confirm-deletion-input"
id="confirm-deletion-input"
value={nameToDeleteInput}
onChange={(_, value) => setNameToDeleteInput(value)}
/>
Expand Down

0 comments on commit 12d8166

Please sign in to comment.