feat: render exact initial layout in the first Fabric commit - #540
Open
kbrattli wants to merge 3 commits into
Open
feat: render exact initial layout in the first Fabric commit#540kbrattli wants to merge 3 commits into
kbrattli wants to merge 3 commits into
Conversation
Add an opt-in exact viewport contract for fixed-size initial-scroll lists. Seed item geometry, content size, containers, and the native offset before mount while retaining the existing bootstrap path for unsupported or mismatched layouts.
Exercise exact snapshot resolution, unsupported fallbacks, first-commit geometry seeding, native visibility gating, viewport invalidation, and the iOS/Android bootstrap settlement split.
Keep the exact-layout hook unconditional for stable hook ordering while platform-resolved guards remove native-only lifecycle work from unsupported bundles.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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.
Closes #539.
Problem
Fabric can commit a list before the ordinary viewport measurement and initial-scroll bootstrap have converged. In transparent modal transitions, a non-zero
initialScrollIndexcan therefore expose an empty or incorrect page before the requested item appears, even when the viewport and every item size are already known before mount.estimatedListSizecannot guarantee this behavior because it is a performance hint rather than a correctness contract.User-facing impact
Applications with exact fixed geometry can opt into
experimental_exactInitialLayout={{ width, height }}so the requested non-zero initial item is present in the first native commit instead of flashing during the opening transition.Existing applications are unchanged unless they opt in.
Reproduction / evidence
To test, run https://github.com/kbrattli/react-native-smooth-clip-view with and without the LegendList patch.
The reproduction opens the third city in a horizontal fixed-size list inside a transparent modal route:
https://github.com/kbrattli/react-native-smooth-clip-view/blob/ff0f76b7b8f1a76fe8be5f9c64f29ee142286d72/example/src/components/ZoomOverlay.tsx
Before
zoom-third-city-legendlist-unpatched-pre-d594.mp4
After
zoom-third-city-legendlist-patched-d594.mp4
Fix
The opt-in exact-layout path resolves before mount and synchronously:
contentOffsetin the first commit;onLoad, adaptive rendering, and normal readiness gated;Safety and fallback behavior
The path is native Fabric-only, single-column, fixed-size, and explicitly experimental. It falls back to the existing bootstrap path, with one-time development warnings, for invalid dimensions or indices, old architecture, web, horizontal RTL, headers, footers, separators, gaps, insets, refresh controls, custom layout or scroll components, sticky or snap indices, window scrolling, anchored end space, end alignment, and measured viewport mismatches.
Android intentionally keeps its existing final corrective scroll even when the seeded offset matches. iOS skips that scroll only after the declared viewport, relevant measured rows, resolved offset, and observed native offset all agree.
Tests
bun test __tests__/core/exactInitialLayout.native.test.tsx __tests__/core/bootstrapInitialScroll.test.ts __tests__/components/LegendList.bootstrapInitialScroll.test.tsx __tests__/components/Containers.native.test.tsx— 68 passedbun run tsc:src— passedbun run lint— 458 files checked, no fixes requiredbun test— 1,649 passed across 119 filesbun run build— passeddist/files are committed.bun run prep-changelog— reported that version 3.3.10 already exists inCHANGELOG.md, so no post-release entry was added.