fix: set list child index correctly #61
Merged
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.
The bug
The list item index is set to be the the parent index, not the child index.
This makes no difference in the web since the browser handles ordered list numbering. However when using this library in React Native, we have to render the list number ourselves, so the React Native library assumes that the
index
refers to the index of the item in the list. (see https://github.com/portabletext/react-native-portabletext/blob/main/src/components/list.tsx#L26)The solution
Here's a screenshot illustrating the change: the text in bold shows the value of
index
before and after the change.I was unable to write a test for this following existing testing patterns, because all the existing tests are snapshots of rendered HTML, which is completely unaffected by this change on the web.