Skip to content

Generate nested scroll view#55239

Closed
Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D90902079
Closed

Generate nested scroll view#55239
Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D90902079

Conversation

@Abbondanzo

@Abbondanzo Abbondanzo commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Summary:
This diff adds the ability to experiment with using NestedScrollView instead of ScrollView as the parent class for ReactScrollView on Android.

Since Java doesn't support multiple inheritance or conditional parent class selection, this is implemented using code generation:

  • A Node script (generate-nested-scroll-view.js) generates ReactNestedScrollView.java and ReactNestedScrollViewManager.kt from their respective source files
  • The generated files are identical to the originals except they extend NestedScrollView instead of ScrollView
  • A Buck genrule (internal) verifies the generated files stay in sync with source files at build time
  • The useNestedScrollViewAndroid feature flag controls which implementation is used at runtime

This approach allows us to safely A/B test the NestedScrollView implementation without requiring JS changes, since both managers register with the same REACT_CLASS name ("RCTScrollView").

Changelog: [Internal]

Differential Revision: D90902079

@meta-codesync

meta-codesync Bot commented Jan 19, 2026

Copy link
Copy Markdown

@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90902079.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 19, 2026
Summary:

This diff adds the ability to experiment with using `NestedScrollView` instead of `ScrollView` as the parent class for `ReactScrollView` on Android.

Since Java doesn't support multiple inheritance or conditional parent class selection, this is implemented using code generation:
- A Python script (`generate-nested-scroll-view.py`) generates `ReactNestedScrollView.java` and `ReactNestedScrollViewManager.kt` from their respective source files
- The generated files are identical to the originals except they extend `NestedScrollView` instead of `ScrollView`
- A Buck genrule verifies the generated files stay in sync with source files at build time
- The `useNestedScrollViewAndroid` feature flag controls which implementation is used at runtime

This approach allows us to safely A/B test the NestedScrollView implementation without requiring JS changes, since both managers register with the same `REACT_CLASS` name (`"RCTScrollView"`).

Changelog: [Internal]

Differential Revision: D90902079
@kkafar

kkafar commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

If this lands, my PR from 2024: #44099 will be eligible for closing.

@meta-codesync meta-codesync Bot closed this in 5e93036 Jan 21, 2026
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 21, 2026
@meta-codesync

meta-codesync Bot commented Jan 21, 2026

Copy link
Copy Markdown

This pull request has been merged in 5e93036.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @Abbondanzo in 5e93036

When will my fix make it into a release? | How to file a pick request?

@Abbondanzo
Abbondanzo deleted the export-D90902079 branch January 21, 2026 22:56
kirillzyusko pushed a commit to kirillzyusko/react-native-keyboard-controller that referenced this pull request Jul 2, 2026
…View (#1527)

## Problem

With React Native's `useNestedScrollViewAndroid` feature flag (RN 0.85+,
react/react-native#55239), `ScrollView` renders as
`ReactNestedScrollView`, which extends
`androidx.core.widget.NestedScrollView` (a `FrameLayout`) — not
`android.widget.ScrollView`.

`ClippingScrollViewDecoratorView.findScrollView` only matches `view is
ScrollView`, so it returns null, `decorateScrollView()` silently no-ops,
and `contentInsetBottom`/`contentInsetTop` are dropped entirely. In a
`KeyboardChatScrollView` this means: list content hides behind the
composer, and `blankSpace`/`extraContentPadding` have no effect on
Android.

## Fix

Match `NestedScrollView` as well, and pass the found view around as
`ViewGroup`. Every member used by the decorator and the padding-scroll
workaround (`clipToPadding`, `getChildAt`, `setPadding`, `scrollBy`,
`scrollY`, `canScrollVertically`, `getLocationOnScreen`) lives on
`ViewGroup`/`View`, and `NestedScrollView` extends its scroll range via
bottom padding + `clipToPadding = false` exactly like `ScrollView`.

`ReactNestedScrollView` itself is package-private, hence matching on the
public androidx base class.

## Testing

Verified in a chat app (RN 0.85.3, new arch,
`useNestedScrollViewAndroid` enabled) via patch-package: composer inset,
keyboard padding, and `blankSpace` all apply again; behavior with the
flag disabled (plain `ScrollView`) is unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants