Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set list child index correctly #61

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

kadikraman
Copy link
Contributor

@kadikraman kadikraman commented Apr 20, 2023

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.

Before After
Screenshot 2023-04-20 at 11 56 09 Screenshot 2023-04-20 at 11 56 34

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.

Copy link
Member

@rexxars rexxars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Thanks!

@rexxars rexxars merged commit 5552d6f into portabletext:main Apr 20, 2023
5 checks passed
@kadikraman kadikraman deleted the fix-list-child-index branch April 20, 2023 17:52
@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants