Skip to content

Commit 03f4609

Browse files
tahierhussainclaude
andcommitted
FIX: Use Ant Design Form pattern for name and description fields
- Replace controlled inputs (value prop) with Form-managed inputs (name prop) - Use Form.useForm() hook and form.setFieldsValue() to set values when editing existing connections - Remove getValueFromEvent which conflicted with controlled input pattern - Move collapseSpaces transformation to onChange handler This fixes the issue where the form fields wouldn't properly display values when editing existing connections. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4bdec24 commit 03f4609

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

frontend/src/base/components/environment/ConnectionDetailsSection.jsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo } from "react";
1+
import { memo, useEffect } from "react";
22
import PropTypes from "prop-types";
33
import { Typography, Input, Select, Form } from "antd";
44

@@ -18,17 +18,24 @@ const ConnectionDetailsSection = memo(
1818
mappedDataSources,
1919
dbUsage,
2020
}) => {
21+
const [form] = Form.useForm();
22+
23+
// Update form values when dbSelectionInfo changes (e.g., when editing a connection)
24+
useEffect(() => {
25+
form.setFieldsValue({
26+
name: dbSelectionInfo.name,
27+
description: dbSelectionInfo.description,
28+
});
29+
}, [form, dbSelectionInfo.name, dbSelectionInfo.description]);
30+
2131
return (
2232
<div className="createConnectionSection flex-1 createConnectionSectionDivider overflow-y-auto">
2333
<Typography className="sectionTitle">Connection Details</Typography>
2434
<div className="formFieldsWrapper">
25-
<Form layout="vertical">
35+
<Form form={form} layout="vertical">
2636
<Form.Item
2737
label="Name"
28-
getValueFromEvent={({ target: { value } }) =>
29-
// collapse any run of 2+ spaces only when followed by non-space
30-
collapseSpaces(value)
31-
}
38+
name="name"
3239
rules={[
3340
{ required: true, message: "Please enter the connection name" },
3441
{ validator: validateFormFieldName },
@@ -37,21 +44,23 @@ const ConnectionDetailsSection = memo(
3744
>
3845
<Input
3946
className="field"
40-
value={dbSelectionInfo.name}
4147
onChange={(e) =>
42-
handleConnectionNameDesc("name", e.target.value)
48+
handleConnectionNameDesc(
49+
"name",
50+
collapseSpaces(e.target.value)
51+
)
4352
}
4453
/>
4554
</Form.Item>
4655

4756
<Form.Item
4857
label="Description"
58+
name="description"
4959
rules={[{ validator: validateFormFieldDescription }]}
5060
>
5161
<Input.TextArea
5262
className="field"
5363
rows={2}
54-
value={dbSelectionInfo.description}
5564
onChange={(e) =>
5665
handleConnectionNameDesc("description", e.target.value)
5766
}

0 commit comments

Comments
 (0)