Remove x,y from measureParentSize — fixes Fabric sticky header offset#2105
Open
thomasttvo wants to merge 3 commits intoShopify:mainfrom
Open
Remove x,y from measureParentSize — fixes Fabric sticky header offset#2105thomasttvo wants to merge 3 commits intoShopify:mainfrom
thomasttvo wants to merge 3 commits intoShopify:mainfrom
Conversation
measureParentSize uses a self-relative measureLayout call (view.measureLayout(view, cb)) to get the view's width and height. The x,y values from this call are always (0,0) on Paper and web since a view's position relative to itself is the origin. The downstream firstItemOffset calculation subtracted outerViewLayout.x/y which was always a no-op. Remove x,y from the return type (Layout -> Size), drop the dead subtractions in RecyclerView, and rename outerViewLayout to outerViewSize to reflect what it actually contains. Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
3b4a327 to
55872e4
Compare
Tests verify that sticky headers don't activate prematurely when measureParentSize returns non-zero y values (as it does on Fabric when there's content above the FlashList). Covers three cases: no content above, 50px above, and 100px above. These tests fail on the old code (which subtracted outerViewLayout.y from firstItemOffset) and pass with the fix. Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Reduce type casts, improve naming, and simplify the describe/test structure for clarity. Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
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.
Summary
measureParentSizeuses a self-relativemeasureLayoutcall (view.measureLayout(view, cb)) to get the outer container's width and height. The returned x,y from this call are always (0,0) on Paper and web — a view's position relative to itself is the origin.The downstream
firstItemOffsetcalculation inRecyclerViewsubtractedouterViewLayout.x/y, which was always a no-op (subtracting 0). This dead subtraction masked a Fabric compatibility issue: on Fabric, the self-relativemeasureLayoutcall returns the view's position in its parent instead of (0,0), corruptingfirstItemOffsetfor any FlashList with content above it.Proof that
view.measureLayout(view, cb)returns (0,0) on Paper: thomasttvo/rn-measure-layout-bug (RN 0.81.5,RCT_NEW_ARCH_ENABLED=0)Repro of downstream effect on sticky headers: thomasttvo/flashlist-sticky-header-repro
Related issues: #1942, #2017
Changes
measureParentSizenow returnsSize({width, height}) instead ofLayout({x, y, width, height})- outerViewLayout.x/ysubtractions fromfirstItemOffsetcalculationouterViewLayouttoouterViewSizeto reflect what it actually containsmeasureLayout.web.tsmeasureParentSizereturns non-zero y (simulating Fabric with content above the FlashList). Tests cover 0px, 50px, and 100px offsets — they fail on the old code and pass with this fix.