fix: typing into the trailing Params/Headers row in the HTTP node no longer destroys the row - #39552
fix: typing into the trailing Params/Headers row in the HTTP node no longer destroys the row#39552dparkmit24 wants to merge 2 commits into
Conversation
The HTTP Request node stores Params/Headers as a newline-joined `key:value` string; `useKeyValueList` round-trips list→string→list on every change. Two issues in that hook destroyed the trailing (uncommitted) row when a user typed the first character into its Value field: 1. `addItem` closed over the render-time `list`, so the `onChange`+`onAdd` pair that fires on the first value keystroke let `onAdd` append to a stale list and overwrite the just-typed value. 2. The microtask effect re-derived the list from the string and reassigned a fresh `id` to every row, remounting the Lexical editor mid-keystroke. Fix (narrow, storage model unchanged): - Keep a `listRef` mirror updated synchronously in `commitList` so `addItem` appends to the latest list, not a stale closure. - Preserve existing rows' ids (positional match) when the effect reconciles from the string, so stable rows are not remounted. Both Params and Headers share this hook and are fixed by the one change. Adds a happy-dom regression test that mounts the real key/value editor (Lexical leaf stubbed) and asserts the trailing row survives a keystroke without the editor remounting. Fails before this change, passes after. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Scope note: |
|
@crazywoola: The linked issue #39551 was erroneously closed when #38861 merged. That PR changes The defect in #39551 is a different one on the Params/Headers tables: typing any non-space character into the trailing row destroys the row, because each keystroke re-derives the list and reassigns every row's This PR carries that fix with its regression test. Happy to rebase if useful. |
Summary
Fixes #39551.
In the HTTP Request node's Params and Headers key/value tables, typing any non-space character into the trailing (uncommitted) row destroyed the entire row — both the just-typed value and any key already entered. Values could only be entered by pasting.
Root cause: params/headers are stored as a newline-joined string, and every change round-trips list → string → list. Two mechanisms in the shared
use-key-value-list.tshook combined to drop input:useEffectre-derived the list from the string on each change and reassigned every row'sid, remounting the Lexical editor mid-keystroke and dropping the character being typed.onChangeimmediately followed by anonAddlet the add overwrite the value that was just typed.Fix: hold a
listRefmirror so the add path no longer closes over a stale list, and preserveids for rows that already exist — only assigning a newidto a genuinely new row — so the editor is no longer remounted on every keystroke. Both tables share the hook, so this fixes Params and Headers together. The newline-joined-string storage model is left unchanged (deliberately out of scope for this fix).Test: added a regression test in the existing Vitest suite that mounts the key-value editor, types into the trailing row's value, and asserts the row survives with its key and value intact. It fails on current
mainand passes with this change; the full workflow-nodes suite andtsc --noEmitstay green.Not addressed here: pressing Enter in the trailing row's key field still migrates the existing value into the newly-created row. That stems from the same newline-joined-string storage model and would require changing it, so it's left as a documented follow-up in #39551.
Screenshots
Before
Typing
openinto the trailing Params value row onmain— the row is destroyed on the first character, losing both the key and the value.2026-07-24_13-36-31.mp4
After
Same sequence with the fix — the row survives, key and value are preserved, and a new empty row appears as expected.
2026-07-24_15-33-28.mp4
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsFrom Claude Code