Commit de058f9
FIX: Connection Name and Description Losing Last Character When Editing (#57)
* 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>
* FIX: Debounce name/description state updates to prevent stale closure
- Add debounced state update for name and description fields (300ms)
- Prevents the handleCreateOrUpdate callback from capturing stale
dbSelectionInfo values during rapid typing
- Ensures the last character is not lost when updating a connection
This fixes the bug where editing connection name from "test_pg" to
"test_pg_edited" would save as "test_pg_edite" (missing last character).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Remove unnecessary debounce from name/description state updates
The debounce was introduced to fix stale closure issues, but it
actually creates a worse bug - a 300ms window where clicking Update
could submit pre-edit values.
The root cause is already fixed in ConnectionDetailsSection.jsx by
using Ant Design's Form pattern (Form.useForm + form.setFieldsValue).
With uncontrolled inputs, the direct state update works correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Add debounce to parent state update in ConnectionDetailsSection
Debounce the handleConnectionNameDesc callback (300ms) to ensure the
parent's handleCreateOrUpdate closure captures the latest state value.
The form input remains responsive since Ant Design manages the input
internally, while the parent state update is debounced.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Apply collapseSpaces synchronously to form value for validation
Update form value synchronously with collapsed spaces so the validator
always sees the processed value, preventing spurious validation errors
when consecutive spaces are typed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Only populate form values when connectionId changes
Change useEffect dependency from dbSelectionInfo fields to connectionId
to prevent form values from being overwritten during typing due to
debounced state updates.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Add isUserEditingRef to prevent form overwrites during typing
- Restore debounce for parent state updates
- Add isUserEditingRef to track when user is actively editing
- Only populate form values when not in editing mode
- Reset editing flag when connectionId changes (new connection loaded)
This ensures:
1. Form populates correctly when async connection data arrives
2. User edits are not overwritten by the useEffect
3. Parent state updates are debounced to prevent stale closure issues
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Use normalize prop for collapseSpaces transformation
Replace manual form.setFieldValue with normalize prop on Form.Item.
This ensures collapseSpaces is applied before storage and validation,
preventing false validation errors when consecutive spaces are typed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Apply collapseSpaces when populating form from server data
setFieldsValue bypasses the normalize prop, so apply collapseSpaces
manually when loading connection data to ensure consistent formatting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* FIX: Move form to parent and use Form.useWatch for hasDetailsChanged
- Move Form.useForm() to CreateConnection.jsx and pass form as prop
- Remove debounce logic from ConnectionDetailsSection (no longer needed)
- Read name/description directly from form in handleCreateOrUpdate
- Use Form.useWatch to reactively track form values for hasDetailsChanged
- This eliminates the race condition and fixes Update button not enabling
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* chore: fix eslint formatting
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: add hasDetailsChanged to deps and normalize original name
- Add hasDetailsChanged to handleCreateOrUpdate dependency array to fix
stale closure issue
- Apply collapseSpaces when storing originalDbSelectionInfo.name to
ensure consistent comparison with form values
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4bdec24 commit de058f9
2 files changed
Lines changed: 45 additions & 32 deletions
Lines changed: 23 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
21 | 35 | | |
22 | 36 | | |
23 | 37 | | |
24 | 38 | | |
25 | | - | |
| 39 | + | |
26 | 40 | | |
27 | 41 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 42 | + | |
| 43 | + | |
32 | 44 | | |
33 | 45 | | |
34 | 46 | | |
35 | 47 | | |
36 | 48 | | |
37 | 49 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| 55 | + | |
49 | 56 | | |
50 | 57 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
Lines changed: 22 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
| |||
118 | 125 | | |
119 | 126 | | |
120 | 127 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
| 137 | + | |
| 138 | + | |
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
| |||
199 | 207 | | |
200 | 208 | | |
201 | 209 | | |
| 210 | + | |
| 211 | + | |
202 | 212 | | |
203 | 213 | | |
204 | 214 | | |
| |||
232 | 242 | | |
233 | 243 | | |
234 | 244 | | |
235 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
236 | 249 | | |
237 | 250 | | |
238 | 251 | | |
| |||
398 | 411 | | |
399 | 412 | | |
400 | 413 | | |
401 | | - | |
402 | | - | |
| 414 | + | |
| 415 | + | |
403 | 416 | | |
404 | | - | |
| 417 | + | |
405 | 418 | | |
406 | 419 | | |
407 | 420 | | |
| |||
428 | 441 | | |
429 | 442 | | |
430 | 443 | | |
431 | | - | |
| 444 | + | |
432 | 445 | | |
433 | 446 | | |
434 | 447 | | |
| |||
0 commit comments