add failing test for ItemSeparatorComponent state bug#55707
add failing test for ItemSeparatorComponent state bug#55707wolf-at-mystro wants to merge 2 commits into
Conversation
|
Hi @wolf-at-mystro! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Co-authored-by: Cursor <cursoragent@cursor.com>
Summary:
Bug: VirtualizedSectionList passes incorrect leading/trailingItem to ItemSeparatorComponent
Our app has a
<SectionList>which was intermittently renderingItemSeparatorComponents with wildly incorrectleadingItem/trailingItemprops, includingundefined, which as far as I can tell should never happen.(While I’m here, I would also like to complain that the type definition for this prop is
React.ComponentType<any>so I also spent a bit of time trying to work out ifundefinedwas even an expected value.)After investigation, it turns out that
ItemWithSeparatorkeeps these values in state, so when the same cell happens to re-render with new props (for example when the virtualized list renders a different region), the separator keeps the previousleadingItem/trailingItem, which can be undefined if that previous row was at a section boundary.I attach here a failing unit test which reproduces this behavior.
Changelog:
[General] [Fixed] - VirtualizedSectionList passes correct leading/trailingItem to ItemSeparatorComponent
Test Plan:
Run the test and observe it failing. I looked into fixing it, but was stymied by the highlighting and updateProps features: they also store state on
ItemWithSeparator, which presumably is equally incorrect when it moves, but I don’t understand what the intended behavior is here or where that state ought to live instead. (For example, if you highlight the separator between items B and C, and item B is removed, should the highlight be transferred to the now A-C separator?)