Repository navigation
Never collapse a collection row without the wrapper - #416
Merged
Merged
Conversation
A row whose definition sets `showCollectionWrapper: false` has no
chevron, so nothing can reopen it once collapsed, and the README
promises it no built-in collapse. But `startCollapsed` and the
`collapseFilter` effect both applied the `collapse` filter to it: the
first render built `CollectionChildren` from a false `hasBeenOpened`
and dropped the rows, and `useCollapseTransition` started it at
`maxHeight: 0`. The memoised node often never re-rendered to recover.
The filter now skips a wrapperless row, so it starts genuinely open.
The two other ways to collapse it are closed off too: a collapse
broadcast ("Collapse All" from an ancestor, `editorRef.collapse`) left
it clipped at zero height once the ancestor reopened, and a click in
the left or property click zone collapsed it (a trap with
`showKey: false`, since the row shrank to nothing clickable). A row
whose definition drops the wrapper while collapsed reopens.
Closes #415
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bundle size impact
|
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 59.02 KB | 59.06 KB | 🔺 +41 B (+0.07%) | 20.89 KB | 20.92 KB | 🔺 +29 B (+0.14%) |
| cjs | 60.46 KB | 60.50 KB | 🔺 +34 B (+0.05%) | 20.92 KB | 20.94 KB | 🔺 +25 B (+0.12%) |
Measured from build/index.{cjs,esm}.js. Gzip at level 9.
Skip the left click zone on a row without the collection wrapper: it
can't collapse the row, so it would only be a dead element over the
indent.
Tighten the tests so each fix is pinned on its own. The max-height
checks read `not.toBe('0')`, which a jsdom that serialises a zero
max-height as '0px' always passes; they now expect '' (an open row
has no max-height). And the render-time reopen of a row that drops its
wrapper also undoes a collapse from the filter or a broadcast on the
next render, so the filter fix and the broadcast guard were masked:
their absence only showed as a transient max-height. The #415 tests
now check the row's max-height before any timer runs, the collapse-all
test becomes a broadcast targeting the visible wrapperless row, and the
click test uses a key click (the `property` zone, which still reaches
`handleCollapse`) plus a check that no left zone renders. Removing any
single fix now fails at least one test.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 #415.
Summary
A collection row whose definition sets
showCollectionWrapper: falsehas no chevron, and the README promises it "no chevron, brackets, or built-in collapse". But three paths could still collapse it, and once collapsed nothing could reopen it:collapsefilter (A row with showCollectionWrapper: false renders no children on first render when the collapse filter matches it #415).startCollapsedand thecollapseFiltereffect didn't considershowCollectionWrapper. The first render builtCollectionChildrenfrom a falsehasBeenOpenedand dropped the rows, anduseCollapseTransitionstarted the node atmaxHeight: 0. The memoised node often never re-rendered to recover.editorRef.collapse) collapsed the row too, leaving it clipped at zero height once the ancestor was reopened with a plain click.showKey: falsethat's a trap: the row shrinks to nothing clickable.Changes
All in
CollectionNode.tsx:showCollectionWrapperis read at the top, and a wrapperless row skips the filter in bothstartCollapsedand the effect. FixingstartCollapsed(rather than moving theisCollapsed/hasBeenOpenedlines aboveCollectionChildren) matters because it also seedsuseCollapseTransition, so the row starts genuinely open instead of rendering its rows into a zero-height box withnodeData.collapsed: true.useAppliedBroadcastgetsNOOPin place ofanimateCollapsefor a wrapperless row, andhandleCollapsereturns early for one. Alt-click on a wrapperless row therefore no longer cascades a collapse to its descendants either..jer-clickzone, which could no longer do anything.Tests
Seven regression tests in
test/customNode.test.tsx. Max-height checks expect''(an open row has none). Apart from the reopen test, where reopening legitimately animates, they run before any timer, so a collapse that later reverses still fails them:collapse={2}, with no max-height (plus thecollapse={false}baseline)componentreceives its rows aschildrenat mountcollapsechanges to match the rowincludeChildren) collapses its descendants but leaves the row without a max-height'property'zone) neither collapses it nor firesonCollapseEach fix was removed on its own and fails at least one test: the filter fix and the broadcast guard (row gets a max-height), the
handleCollapseguard (onCollapsefires), the click-zone conditional (zone rendered) and the reopen line (rows missing). Againstmain'sCollectionNodesix fail. Full suite, lint andtscpass.🤖 Generated with Claude Code