Skip to content

[Android] Horizontal ScrollView ignores collapsableChildren, so maintainVisibleContentPosition loses empty anchor views #60183

Open

Description

@afonsojramos

Description

On Android with the new architecture, maintainVisibleContentPosition cannot anchor on an empty child view in a horizontal ScrollView. The same view works as an anchor in a vertical ScrollView.

When maintainVisibleContentPosition is set, ScrollView passes collapsableChildren={false} to its content view so that Fabric keeps its children as native views. On Android, a vertical ScrollView uses a plain View as the content view, and ViewShadowNode honours collapsableChildren. A horizontal ScrollView uses AndroidHorizontalScrollContentView, whose shadow node is a ConcreteViewShadowNode that never reads collapsableChildren. Its children are flattened as usual, so a child with no visual props never reaches the native view tree, and MaintainVisibleScrollPositionHelper anchors on a different view.

This breaks list libraries that use an empty view as their scroll-adjust anchor. For example, Legend List moves a 0×0 view to compensate for size changes, and in horizontal lists the native offset never follows it (LegendApp/legend-list#620). Setting collapsable={false} on the child works around it (LegendApp/legend-list#619). iOS is not affected, because ScrollContentView maps to View there.

The code is unchanged on main: AndroidHorizontalScrollContentViewShadowNode still extends ConcreteViewShadowNode, which sets FormsView and FormsStackingContext but not ChildrenFormStackingContext.

Steps to reproduce

  1. Run the reproducer below on Android with the new architecture.
  2. Press Move horizontal anchor and Move vertical anchor a few times. Each press moves an empty, absolutely positioned child of the ScrollView by 100.
  3. Compare the two offsets.

Expected: both offsets grow by 100 per press, because maintainVisibleContentPosition keeps the anchor in place.

Actual: the vertical offset grows by 100 per press (100, 200, 300). The horizontal offset stays at 0. With collapsable={false} on the anchor view, the horizontal offset also grows (100, 200, 300).

React Native Version

0.86.3 (also seen on 0.88.1 through Legend List)

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: macOS 27.2.1
  CPU: (10) arm64 Apple M5
  Memory: 995.89 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 26.13.1
    path: ~/.local/share/mise/installs/node/26.13.1/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.local/share/nub/shims/yarn
  npm:
    version: 11.20.0
    path: ~/.local/share/nub/shims/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.17.0
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 27.2
      - iOS 27.2
      - macOS 27.2
      - tvOS 27.2
      - visionOS 27.2
      - watchOS 27.2
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 27.2/27B52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.21.0.3
    path: ~/.local/share/mise/installs/java/zulu-17.70.113.0/bin/javac
  Ruby:
    version: 4.0.9
    path: /opt/homebrew/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.2.7
    wanted: 19.2.7
  react-native:
    installed: 0.86.3
    wanted: 0.86.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

The app is an Expo dev client on the new architecture (the default for this version), tested on an Android 15 emulator.

Stacktrace or Logs

No crash or error. In `adb shell dumpsys activity top`, the horizontal ScrollView's content view has no child for the anchor view. With collapsable={false} on the anchor, it appears as the first child.

MANDATORY Reproducer

Snack: Horizontal ScrollView ignores collapsableChildren (Android, the code is in the link)

The same code as an RNTesterPlayground.js file: https://gist.github.com/afonsojramos/ef4c3b9482bd83ad152b97e5d73070e9

Screenshots and Videos

No response

Activity

  1. react-native-bot commented on Nov 20, 2026

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  2. afonsojramos commented on Nov 20, 2026

    @afonsojramos
    Author

    I've added a Snack to the reproducer section. It runs the same code as the RNTesterPlayground gist: press both buttons on Android and the horizontal offset stays at 0 while the vertical one follows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions