Keep live child rows during edit for showOnEdit collection custom nodes (#384)#385
Merged
CarlosNZ merged 1 commit intoJun 25, 2026
Conversation
…es (#384) A collection custom `component` with `showOnEdit: true` owns the node's editor, so it now receives the live child rows as `children` while editing — the same as in view — instead of the built-in raw-JSON `<textarea>`. This lets such a node compose an editable header/toolbar above rows that stay visible and interactive throughout the edit; it commits collection-level changes through `setValue` and owns its commit affordance (`setIsEditing` / `handleEdit` / `handleCancel`). Standard collection editing (showOnEdit falsy, or no custom component) is unchanged and still yields the textarea. - Core: `customOwnsEdit` predicate in CollectionNode (reuses the child-rows JSX) - Tests: regression + showOnEdit:false guard in customNode.test.tsx - Example: new "Playlist" page (editable Reorder toolbar over live track rows) - Docs: README_V2 note + Live-example badge, migration-guide note, changeset 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 | 57.69 KB | 57.71 KB | 🔺 +17 B (+0.03%) | 20.60 KB | 20.61 KB | 🔺 +10 B (+0.05%) |
| cjs | 59.19 KB | 59.21 KB | 🔺 +17 B (+0.03%) | 20.63 KB | 20.64 KB | 🔺 +9 B (+0.04%) |
Measured from build/index.{cjs,esm}.js. Gzip at level 9.
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 #384.
What
When a collection custom node owns its editor (
showOnEdit: true+ a customcomponent), itschildrennow stays the live child rows while editing — the same as in view — instead of being swapped for the built-in raw-JSON<textarea>. This is the new default:showOnEdit: truealready means "I supply this node's editor", so handing it the library's own textarea aschildrenwas incoherent.This lets a node compose
toolbar + {children}in both states and lean entirely on the built-inEditingProvider— e.g. an Operator/Fragment-style header that keeps its children visible and interactive while the header is in edit mode.How
src/CollectionNode.tsx: acustomOwnsEdit = !!CustomComponent && showOnEditpredicate gatesCollectionChildrenso the live child rows render whenever the custom component owns the edit state. The existing child-rows JSX is reused verbatim; the textarea branch (and its OK/Cancel buttons) only fires for standard collection editing. The buffer/parse plumbing (editBufferValue/handleEdit) simply goes unused for these nodes — nothing removed.No new prop. A custom editor commits collection-level changes via the
setValueit already receives, and owns its commit affordance (setIsEditing/handleEdit/handleCancel). The publicAutogrowTextArearemains exported for anyone who wants the built-in textarea's look.Compatibility
Behaviour change for an existing
showOnEdit: truecollection custom node that rendered{children}expecting the JSON textarea — it now gets the live rows. The one genuinely removed capability is "custom chrome wrapped around the built-in JSON textarea editor";showOnEdit: falseis not an equivalent (it drops the custom component entirely during edit). The changeset and migration-guide note say this explicitly. Acceptable in v2-beta.Example
New Playlist example page:
tracksis ashowOnEdit: truecustom node whose header shows count + runtime and a "Reorder…" toolbar (Shuffle / Sort / Reverse, committing viasetValue) that appears while the track rows stay live and editable beneath it. Editing a track inline during the header session simply displaces it (single active session).Tests
showOnEdit:truecollection edit; fails before the fix at exactly the right line).showOnEdit:falseguard (standard collection editing still yields the textarea).tscclean for core and demo.Not yet done
Interactive browser click-through wasn't possible in this environment — verified the dev server boots and the example module transforms without errors, but the manual "click Reorder, edit a track inline, watch the session displace" walkthrough is the remaining check.
🤖 Generated with Claude Code