Skip to content

Commit 38dd2ec

Browse files
authored
fix(frontend): prevent page refresh when pressing Enter in API input fields (#559)
## 📝 Pull Request Template ### 1. Related Issue Closes #544 ### 2. Type of Change (select one) Type of Change: Bug Fix ### 3. Description prevent page refresh when pressing Enter in API input fields (api host and api key form) ### 4. Testing - [x] I have tested this locally. - [x] I have updated or added relevant tests. ### 5. Checklist - [x] I have read the [Code of Conduct](./CODE_OF_CONDUCT.md) - [x] I have followed the [Contributing Guidelines](./CONTRIBUTING.md) - [x] My changes follow the project's coding style
1 parent 79bd6e7 commit 38dd2ec

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

frontend/src/app/setting/components/models/model-detail.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ export function ModelDetail({ provider }: ModelDetailProps) {
181181
value={field.state.value}
182182
onChange={(e) => field.handleChange(e.target.value)}
183183
onBlur={() => configForm.handleSubmit()}
184+
onKeyDown={(e) => {
185+
if (e.key === "Enter") {
186+
e.preventDefault();
187+
e.currentTarget.blur();
188+
}
189+
}}
184190
/>
185191
<InputGroupAddon align="inline-end">
186192
<InputGroupButton
@@ -228,6 +234,12 @@ export function ModelDetail({ provider }: ModelDetailProps) {
228234
value={field.state.value}
229235
onChange={(e) => field.handleChange(e.target.value)}
230236
onBlur={() => configForm.handleSubmit()}
237+
onKeyDown={(e) => {
238+
if (e.key === "Enter") {
239+
e.preventDefault();
240+
e.currentTarget.blur();
241+
}
242+
}}
231243
/>
232244
<FieldError errors={field.state.meta.errors} />
233245
</Field>

0 commit comments

Comments
 (0)