Repository navigation
Don't call VirtualizedList's onLayout with the ListEmptyComponent's layout - #60149
kagantemizkan wants to merge 2 commits into
Conversation
…ayout When the list is empty, VirtualizedList called the list's onLayout twice: once from the ScrollView with the list's own frame, and once from _onLayoutEmpty with the frame of ListEmptyComponent. Remove _onLayoutEmpty; the empty component's own onLayout is still called.
|
Hi @kagantemizkan! 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! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
It's no longer necessary to override this now, you can remove this completely,
There was a problem hiding this comment.
Done in 80ae7a1: the onLayout override is gone, so the clone only adds the inversion style (still needed for inverted lists; Fragments are still returned as is). I updated the tests too: the cloned element no longer gets an onLayout, and the new test checks that the empty component's own onLayout still runs while the list's doesn't.
cloneElement keeps the element's own onLayout, so the wrapper is no longer needed now that it only called that handler.
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D133240954. |
Summary:
When the list is empty,
VirtualizedListcalls the list'sonLayouttwice: once from theScrollViewwith the list's own frame, and once from_onLayoutEmptywith the frame ofListEmptyComponent. The second call reports the empty component's position and size inside the content container, so code that sizes things from the list's width (columns, tile sizes) picks up the wrong width whenever the empty component has a margin or padding._onLayoutEmptycame in withListEmptyComponentin 2017 (264d67c). The header and footer handlers next to it store their own length; the empty one only forwards its event toprops.onLayout, which looks unintended. This removes it. The empty component's ownonLayoutis still called.Changelog:
[GENERAL] [FIXED] -
VirtualizedList(andFlatList/SectionList) no longer callsonLayoutwith the layout ofListEmptyComponentTest Plan:
VirtualizedList-test.js: the list'sonLayoutis not called when the empty component lays out. It fails onmain(1 call, expected 0) and passes with this change. The whole file passes (89 passed, 1 skipped), andflow full-check, ESLint and Prettier are clean.FlatListwithmargin: 8and aListEmptyComponentwithmargin: 24, logging everyonLayoutcall:onLayoutcallsx=8 y=221 w=386 h=464, thenx=24 y=24 w=338 h=66x=8 y=221 w=386 h=464only; the empty component's ownonLayoutstill getsx=24 y=24 w=338 h=66x=8 y=221 w=386 h=464only