Skip to content

Editing store: drop dead previouslyEditedElement / tabDirection state (#334 follow-up)#353

Merged
CarlosNZ merged 2 commits into
334-tab-viabilityfrom
334-followup-store-cleanup
Jun 12, 2026
Merged

Editing store: drop dead previouslyEditedElement / tabDirection state (#334 follow-up)#353
CarlosNZ merged 2 commits into
334-tab-viabilityfrom
334-followup-store-cleanup

Conversation

@CarlosNZ

Copy link
Copy Markdown
Owner

Stacked on #352. Merge that one first.

Follow-up cleanup queued from #352's plan. After the redirect useLayoutEffect retirement landed, previouslyEditedElement and tabDirection became write-only state — the only writers (recordPreviousEdit, setTabDirection) had no remaining readers anywhere in src/ or test/. Audit:

grep -rn 'previouslyEditedElement|recordPreviousEdit' src test
  → only declarations + the writer call in ValueNodeWrapper.tabTo

grep -rn 'tabDirection|setTabDirection' src test
  → only declarations + the writer call in ValueNodeWrapper.tabTo

Changes

  • EditingStateBundle loses previouslyEditedElement: CollectionKey[] | null and tabDirection: TabDirection.
  • EditingStore loses recordPreviousEdit and setTabDirection. Shape is now { subscribe, getSnapshot, getServerSnapshot, open, cancel, submit, areChildrenBeingEdited }.
  • ValueNodeWrapper.tabTo drops the two store calls. The viability-aware getNextOrPreviousAtPath (from Tab viability: skip non-viable targets, retire redirect useLayoutEffect (#334) #352) already skips non-viable Tab targets up front, which is the role those store fields used to support.
  • Unused TabDirection import removed from EditingProvider.
  • useEditing public hook's return shape shrinks correspondingly (the two action methods are no longer exposed).

Test plan

Diff stat

File Delta
src/contexts/EditingProvider.tsx −22
src/ValueNodeWrapper.tsx −15
.changeset/*.md +3

🤖 Generated with Claude Code

…te (#334 follow-up)

After the redirect useLayoutEffect retirement, both `previouslyEditedElement`
and `tabDirection` were write-only — `recordPreviousEdit` / `setTabDirection`
had no readers. Audit confirmed nothing in src/ or test/ consumes either.

Drops the two state fields from `EditingStateBundle`, the two action methods
from `EditingStore`, the unused `TabDirection` import, and the corresponding
calls from `ValueNodeWrapper.tabTo` (the viability-aware `getNextOrPreviousAtPath`
already handles non-viable Tab targets up front). Public `useEditing` hook
shape shrinks accordingly.

Net: -22 lines on EditingProvider, -15 lines on ValueNodeWrapper (~37 removed,
0 added that count beyond moved comment text).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Bundle size impact

json-edit-react

Format Base raw PR raw Δ raw Base gzip PR gzip Δ gzip
esm 56.03 KB 55.76 KB 🟢 -280 B (-0.49%) 20.10 KB 20.01 KB 🟢 -89 B (-0.43%)
cjs 57.56 KB 57.29 KB 🟢 -281 B (-0.48%) 20.19 KB 20.10 KB 🟢 -91 B (-0.44%)

Measured from build/index.{cjs,esm}.js. Gzip at level 9.

@CarlosNZ CarlosNZ merged commit 52ea727 into 334-tab-viability Jun 12, 2026
2 checks passed
@CarlosNZ CarlosNZ deleted the 334-followup-store-cleanup branch June 12, 2026 12:57
CarlosNZ added a commit that referenced this pull request Jun 12, 2026
…ct (#334) (#352)

* Tab viability: skip non-viable targets in getNextOrPrevious (#334)

Retires the redirect useLayoutEffect in ValueNodeWrapper. `getNextOrPrevious`
gains an optional `isViable` predicate; `useCommon` composes it from
`filterState.visiblePaths` (new `useRawFilterState` hook) and the existing
`allowEditFilter`. Tab navigation skips filtered-out and non-editable nodes
up front instead of opening and bouncing, eliminating the spurious
startEdit/cancelEdit observer pairs on dead-end nodes.

KeyDisplay's Tab path (key-edit → value-edit) inherits the same viability
check, since both source roles share `getNextOrPreviousAtPath` via
useCommon.

Behaviour changes:
- No `previouslyEditedElement` fallback when no viable next exists; the
  editor cancels cleanly instead.
- Live search hiding the actively-edited node leaves the editing record
  in the store; the input unmounts via the existing `!isVisible`
  early-return. Clearing the search later resumes the edit. No
  off-screen-commit footgun because there's no input to commit through.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* PR #352 review: required isViable param + extract buildNodeData

- `getNextOrPrevious`: drop the optional `?` on `isViable`. The only no-
  predicate callers were tests; production (`useCommon`) always supplies
  one. Tests now pass `acceptAll = () => true` for the pure structural
  walk. The "absence of the predicate is byte-equivalent" case is gone —
  trivially true under a required predicate.
- `buildLeafNodeData` (inline in `keyboard.ts`) was a near-duplicate of
  `buildNodeData` in `JsonEditor.tsx`. Extracted the canonical builder
  to `src/utils/buildNodeData.ts` and reuse from both call sites.
  `rootName` defaults to `''` for callers that never target the root.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* Editing store: remove dead previouslyEditedElement / tabDirection state (#334 follow-up) (#353)

After the redirect useLayoutEffect retirement, both `previouslyEditedElement`
and `tabDirection` were write-only — `recordPreviousEdit` / `setTabDirection`
had no readers. Audit confirmed nothing in src/ or test/ consumes either.

Drops the two state fields from `EditingStateBundle`, the two action methods
from `EditingStore`, the unused `TabDirection` import, and the corresponding
calls from `ValueNodeWrapper.tabTo` (the viability-aware `getNextOrPreviousAtPath`
already handles non-viable Tab targets up front). Public `useEditing` hook
shape shrinks accordingly.

Net: -22 lines on EditingProvider, -15 lines on ValueNodeWrapper (~37 removed,
0 added that count beyond moved comment text).

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant