Skip to content

Commit b348949

Browse files
fix(site): Confirm delete on press Enter in delete dialog (#7720)
1 parent be2067b commit b348949

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

site/src/components/Dialogs/DeleteDialog/DeleteDialog.tsx

+23-14
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,29 @@ export const DeleteDialog: FC<PropsWithChildren<DeleteDialogProps>> = ({
4141
</Maybe>
4242
<p>{t("deleteDialog.confirm", { entity })}</p>
4343

44-
<TextField
45-
fullWidth
46-
autoFocus
47-
className={styles.textField}
48-
name="confirmation"
49-
autoComplete="off"
50-
id="confirmation"
51-
placeholder={name}
52-
value={nameValue}
53-
onChange={handleChange}
54-
label={t("deleteDialog.confirmLabel", { entity })}
55-
error={hasError}
56-
helperText={hasError && t("deleteDialog.incorrectName", { entity })}
57-
/>
44+
<form
45+
onSubmit={(e) => {
46+
e.preventDefault()
47+
if (confirmed) {
48+
onConfirm()
49+
}
50+
}}
51+
>
52+
<TextField
53+
fullWidth
54+
autoFocus
55+
className={styles.textField}
56+
name="confirmation"
57+
autoComplete="off"
58+
id="confirmation"
59+
placeholder={name}
60+
value={nameValue}
61+
onChange={handleChange}
62+
label={t("deleteDialog.confirmLabel", { entity })}
63+
error={hasError}
64+
helperText={hasError && t("deleteDialog.incorrectName", { entity })}
65+
/>
66+
</form>
5867
</>
5968
)
6069

0 commit comments

Comments
 (0)