fix(ui): trim both sides of delete confirmation compare

A stored team or credential name with surrounding spaces would never
match a trimmed paste. Compare the trimmed stored name too.
This commit is contained in:
chahatkesh 2026-08-29 14:36:24 +05:30
parent 9719747080
commit 9000134849
2 changed files with 8 additions and 1 deletions

View file

@ -134,6 +134,12 @@ describe("DeleteResourceModal", () => {
expect(screen.getByRole("button", { name: /delete/i })).toBeDisabled();
});
it("should enable delete when the stored name itself has surrounding whitespace", () => {
renderWithProviders(<DeleteResourceModal {...defaultProps} requiredConfirmation=" prod-key " />);
fireEvent.change(screen.getByRole("textbox"), { target: { value: "prod-key" } });
expect(screen.getByRole("button", { name: /delete/i })).toBeEnabled();
});
it("should reset requiredConfirmation input when modal opens", async () => {
const user = userEvent.setup();
const { rerender } = renderWithProviders(<DeleteResourceModal {...defaultProps} requiredConfirmation="DELETE" />);

View file

@ -102,7 +102,8 @@ export default function DeleteResourceModal({
variant="destructive"
onClick={onOk}
disabled={
(!!requiredConfirmation && requiredConfirmationInput.trim() !== requiredConfirmation) || confirmLoading
(!!requiredConfirmation && requiredConfirmationInput.trim() !== requiredConfirmation.trim()) ||
confirmLoading
}
>
{confirmLoading ? "Deleting..." : "Delete"}