Skip to content

Commit df1e8b6

Browse files
committed
fix(web): rename dialog submits through its form so IME Enter does not save early
1 parent 37eefa9 commit df1e8b6

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

‎apps/web/src/components/settings/EnvironmentRenameDialog.tsx‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ function EnvironmentRenameForm({
9393
};
9494

9595
return (
96-
<>
96+
<form
97+
className="flex min-h-0 flex-col"
98+
onSubmit={(event) => {
99+
event.preventDefault();
100+
submit();
101+
}}
102+
>
97103
<DialogHeader>
98104
<DialogTitle>Rename environment</DialogTitle>
99105
<DialogDescription>
@@ -110,19 +116,14 @@ function EnvironmentRenameForm({
110116
maxLength={64}
111117
value={name}
112118
onChange={(event) => setName(event.target.value)}
113-
onKeyDown={(event) => {
114-
if (event.key === "Enter") {
115-
event.preventDefault();
116-
submit();
117-
}
118-
}}
119119
/>
120120
</div>
121121
{lock !== null ? <p className="text-xs text-muted-foreground">{lock}</p> : null}
122122
</DialogPanel>
123123
<DialogFooter>
124124
{customLabel !== null ? (
125125
<Button
126+
type="button"
126127
variant="ghost"
127128
className="sm:mr-auto"
128129
disabled={lock !== null}
@@ -131,13 +132,13 @@ function EnvironmentRenameForm({
131132
Use default name
132133
</Button>
133134
) : null}
134-
<Button variant="outline" onClick={onClose}>
135+
<Button type="button" variant="outline" onClick={onClose}>
135136
Cancel
136137
</Button>
137-
<Button disabled={lock !== null} onClick={submit}>
138+
<Button type="submit" disabled={lock !== null}>
138139
Save
139140
</Button>
140141
</DialogFooter>
141-
</>
142+
</form>
142143
);
143144
}

0 commit comments

Comments
 (0)