fix!: render lists using direct nesting mode - #280
Draft
rexxars wants to merge 3 commits into
Draft
Conversation
Lists were nested the way HTML needs them to be, where a deeper list has to live inside a list item because HTML cannot put a list directly inside a list. React Native has no such restriction, so this rendered a `View` inside the `Text` of the list item above it. It also meant that levels the author never wrote - a list starting at level 3, or one skipping from level 1 to level 3 - had to be filled with an empty list item, which draws a bullet or a number with no content next to it. `direct` mode fills those levels with a bare list instead, so they indent without drawing a marker. BREAKING CHANGE: nested lists are no longer rendered inside the list item that precedes them, but as a sibling of it, directly inside the parent list. Custom `list` and `listItem` components that relied on the old shape may need adjusting. `value.level` is unchanged and still matches the nesting depth.
BREAKING CHANGE: Node.js 22.12 or later is required.
🦋 Changeset detectedLatest commit: 80b9998 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Warning
Blocked. This needs the next major of
@portabletext/react, which is not published yet (see portabletext/react-portabletext#340). CI will fail until that lands and the dependency here is bumped. Opened as a draft so the work is not lost.What this changes
Lists were nested the way HTML needs them to be, where a deeper list has to live inside a list item because HTML cannot put a list directly inside a list. React Native has no such restriction, so this rendered a
Viewinside theTextof the list item above it.It also meant that levels the author never wrote, such as a list starting at level 3 or one skipping from level 1 to level 3, had to be filled with an empty list item, which draws a bullet or a number with no content next to it.
Passing
listNestingMode="direct"nests a deeper list straight inside its parent list instead. Generated levels become bare lists, so they indent without drawing a marker.Rendering
[level 3 number, level 1 number], before:After:
Breaking
Nested lists are no longer rendered inside the list item that precedes them, but as a sibling of it, directly inside the parent list. Custom
listandlistItemcomponents that relied on the old shape may need adjusting.value.levelis unchanged and still matches the nesting depth.engines.nodeis also raised to>=22.12.Still to do before this can merge
@portabletext/reactfrom^4.0.3to the new major once it is published. That is a four major jump, somergeComponentsand the component prop types need verifying, not just a range edit.DefaultListusespaddingLeft: 16 * value.levelon a nestedView, so indentation compounds to 16 + 32 + 48 = 96 for a level 3 item rather than 48. Now that nesting depth always equalslevel, a flatpaddingLeft: 16per nested list is the correct fix.Verification
Verified by linking
@portabletext/toolkit@6.0.0under the existing@portabletext/react@4.0.3, which confirms the rendering change. 4 snapshots updated, 34 pass, type-check clean. Against the currently resolved dependencies, 1 snapshot fails, which is the blocker above.Refs portabletext/toolkit#100