Schema - Fix Add HTTP Header button losing rows on double-click#4100
Schema - Fix Add HTTP Header button losing rows on double-click#4100geodem127 wants to merge 12 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6d3b17a to
9219322
Compare
…o array Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Review summaryThe refactor from A few follow-ups worth addressing before merge:
Test coverageThe existing tests in Nits
|
…stale closures
- Restore Record<uuid, {key, value}> shape so row keys are stable across
deletes (array-index keys break focus and reconciliation when a preceding
row is removed)
- Re-add uuidv4() import; generate a UUID per row on init and on Add
- Track focusRef as string | "url" instead of number | "url"
- Type onChange callbacks as React.ChangeEvent<HTMLInputElement> instead of any
- Use functional setHeadersLocal((prev) => ...) in all onChange handlers to
avoid stale closure captures
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReviewThe core fix — switching A few notes worth addressing before merge: 1. PR description doesn't match the implementationThe description's "Note" claims the final implementation switched 2. Test coverage gapThe existing assertions in 3. Minor inline nitsPosted as inline comments. 🤖 Generated with Claude Code |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Re-review on commit
|
…hema-button-loses-rows-on-double-click
|
Regarding the minor observation: always rendering at least one row and hiding the first row's delete button is intentional per design — the field should never present an empty state with no header rows visible. |
…ithub.com:zesty-io/manager-ui into fix/4094-schema-button-loses-rows-on-double-click
ReviewTight, focused fix — the diff is mostly the right cleanup, and both changes are needed together rather than redundant. A few notes: Root cause framingThe PR description leads with
Worth noting in the description so future readers don't mistakenly think swapping just the key generator would have fixed it. Missing automated coverageThe Cypress suite has selectors for Nits (non-blocking)
LGTM on the fix itself. |
|
PR description updated to lead with the stale closure as the primary root cause and frame Nits applied:
Cypress: acknowledged as a pre-existing structural issue (nested |
…ut handler Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ithub.com:zesty-io/manager-ui into fix/4094-schema-button-loses-rows-on-double-click
ReviewVerdict: Looks good — the diagnosis is correct and the fix is well-targeted. Strengths
Minor
Pre-existing, not in scopeNoting these only so they're on the radar — none are introduced by this PR:
Nice clean fix overall. |
…hema-button-loses-rows-on-double-click
ReviewClean, targeted fix. The root-cause diagnosis is accurate and both countermeasures are appropriate. What's good
ConcernsCypress test coverage gap — The existing
See inline comments for two additional minor items. |
|
PR #4153 fixes failing and flaky tests |
Summary
The root cause was a stale closure on
headersLocalinside the click handler: the handler captured a snapshot of headers at render time, so a second click in the same render cycle spread{...staleHeaders, [uuid2]: ...}, silently overwriting the row added by the first click.Two complementary fixes:
(prev) => ({...prev, [id]: ...})so each click composes from the latest state rather than a stale closure capture. This is the primary fix.uuidv4()for row keys — replacesDate.now().toString()as defense-in-depth: twoDate.now()calls in the same millisecond produce the same key, masking the stale-closure bug as a silent overwrite. Unique UUIDs surface any future key collision as a visible problem.Test plan
🤖 Generated with Claude Code
NOTE: This PR is required to resolve a failing test #4153