Skip to content

Commit f9340f0

Browse files
generatedunixname1608173377072046meta-codesync[bot]
authored andcommitted
Fix VirtualView clipping with stale parent offset on Android
Summary: WARNING: Generated by Autopilot (alpha) — review carefully, verify the underlying claim before accepting. Agent: [Bugs Agent v2](https://www.internalfb.com/autopilot/marketplace?agent=1525997276001839) | SC job: https://www.internalfb.com/intern/sandcastle/instance/4503602683697923/ --- **Problem:** With subview clipping on (`rn_fling.support_subview_clipping`), `ReactVirtualView` cells that are inside the scroll viewport can lose their children and render blank until the user scrolls again. On the FB4A Marketplace home feed the "Newly listed" module showed only its header pill with an empty body (T294050483). **Reproduction:** Fling the Marketplace Explore feed with clipping on. On master, 13–17 of 48 settled scroll states left the top on-screen row blank whenever up to 128 px of it, the list column's offset within the scroll content, was visible. **Fix:** `doAttachedToWindow()` now always calls `updateParentOffset()`. Fabric attaches a view before laying it out, and ancestors that are already laid out don't fire `onLayoutChange` again, so the offset used to stay 0 and the clipping rect was shifted. `recycleView()` now resets `offsetX`/`offsetY` so a recycled view doesn't keep the previous parent's offset. Reporting to `VirtualViewContainer` still waits for the first layout. **Caveat:** The production "Newly listed" module never rendered for the test user because it depends on local inventory and server gating, so the mechanism was verified on other feed cells and on a mocked module. A view that is detached and reattached without a new layout still isn't re-registered with the container until its next layout. Changelog: [Android][Fixed] - Fix VirtualView clipping on-screen content when its parent offset was not computed at attach time Reviewed By: christophpurrer Differential Revision: D126932544 fbshipit-source-id: dce0b1d0cb0bbbb1da162126082f55989284e904
1 parent da42db9 commit f9340f0

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/virtual/view

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/virtual/view/ReactVirtualView.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public class ReactVirtualView(context: Context) :
5151
@VisibleForTesting
5252
internal fun doAttachedToWindow() {
5353
scrollView = getScrollView()
54+
// Ancestors that are already laid out won't fire onLayoutChange again, so the offset must be
55+
// computed here even if this view hasn't had its own layout yet.
5456
updateParentOffset()
5557
// onAttachedToWindow is usually called before layout but there are cases where it's called
5658
// after. If called after, we need to report the updated layout to the VirtualViewContainer

0 commit comments

Comments
 (0)