Commit open edit when displaced by clicking another node (#376) - #379
Merged
CarlosNZ merged 3 commits intoJun 22, 2026
Conversation
Opening an edit on another node (its pencil, double-clicking another value, or clicking another key to rename) now COMMITS the in-progress edit instead of cancelling it — matching Tab. Previously the two "leave this field and go edit elsewhere" gestures behaved oppositely (Tab committed, click-away discarded), silently dropping typed text. Behaviour now mirrors Tab: - changed edit -> commits (onUpdate runs), then opens the new node - unchanged edit -> closes via commit* (no onUpdate / setData), opens new - can't commit (malformed JSON, duplicate key, throwing fromStandardType) -> switch is BLOCKED; editor stays open with its inline error - object-add session -> still cancels (you can't Tab out of a new-key edit) The outgoing node registers a commit-on-displace callback in the editing store (alongside cancelOp); open() invokes it on a switch, deferring the new node's opening into the commit's onCommit. The callback forwards to the node's LIVE handleEdit via a ref so it commits the current buffer, not a stale closure. submit() now also abandons gracefully if a commit-on-displace fires for a session whose node already unmounted. Includes rewritten + new regression tests, the A8 manual-test matrix, a changeset, and migration-guide / README notes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bundle size impact
|
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 56.71 KB | 57.27 KB | 🔺 +574 B (+0.99%) | 20.30 KB | 20.45 KB | 🔺 +149 B (+0.72%) |
| cjs | 58.19 KB | 58.76 KB | 🔺 +587 B (+0.99%) | 20.33 KB | 20.49 KB | 🔺 +162 B (+0.78%) |
Measured from build/index.{cjs,esm}.js. Gzip at level 9.
CarlosNZ
deleted the
376-correct-behaviour-when-clicking-edit-on-another-node-when-session-is-open
branch
June 22, 2026 23:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #376.
What & why
Opening an edit on another node — clicking its ✎ pencil, double-clicking another value, or clicking another key to rename — currently cancels the in-progress edit. But Tab commits then moves. The two "leave this field and go edit elsewhere" gestures behaved oppositely, so typing a value and clicking the next field silently discarded the typed text.
This makes a click-to-another-node switch behave like Tab.
Behaviour (the contract the tests pin)
commitEdit+onUpdate, open newsubmitEdit+commitEdit(noonUpdate/setData), open newcommitRename+onUpdate, open newcommitRename(noonUpdate), open newcancelAdd, open newcancelAdd, open newcommit*(consistent with Tab), incl. no-op rename →commitRename(now flagged viabuildCommitisNoOp: oldKey === newKey; also aligns Tab-off-an-unchanged-key).addis the exception — a displace still cancels it (you can't Tab out of a new-key edit). Implemented simply by not registering a commit callback for add.How
open()is called by the incoming one, so the outgoing node registers a commit-on-displace callback in the editing store, alongside today'scancelOp.open(), on a switch, calls it and defers opening the new node into the commit'sonCommit(synchronous for editor ops, so it still feels instant) — no re-entrancy intoopen().handleEditvia a ref — a closure frozen atopen()time would commit the stale initial buffer (the ref hooks sit above the!isVisibleearly returns to keep hook order stable).submit(soonCommitnever runs → switch blocked); a no-op routes throughsubmit'sisNoOpbranch.submit()now also abandons gracefully if a displace fires for a session whose node already unmounted (buildCommitwould otherwise throw on the vanished path).Touches:
EditingProvider(store),ValueNodeWrapper,CollectionNode,KeyDisplay+useCommon(rename),JsonEditor(buildCommit).Tests & docs
onEditEventcontract shift in the migration guide (§10) + an end-user README bullet.pnpm test(653 pass),pnpm compile,pnpm lintall green.Note for review
One behaviour change slightly beyond the strict displace scope, for consistency: a duplicate-key rename on Enter now keeps the editor open with the error instead of closing (matching value/collection invalid handling). And the automated suite can't reproduce the Firefox DnD phantom-dragstart path — a quick Firefox walk of the A8 matrix (incl. a drag right after a commit-on-displace) is worth doing before merge, though the
draggableflip logic is untouched.🤖 Generated with Claude Code