add option to disable prop scrollView.maintainVisibleContentPosition (#53465)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53465

changelog: [internal]

I am debugging an issue with Fabric View Culling + immediate state update.
The problem appears to be in logic handling `maintainVisibleContentPosition`. I want to try to disable the prop to see if the problem goes away.

Reviewed By: rshest

Differential Revision: D81030436

fbshipit-source-id: 8efeb1151ad3e12b812cafd073348502510ef01d
This commit is contained in:
Samuel Susla
2025-08-26 15:12:41 -07:00
committed by Facebook GitHub Bot
parent 2b99204e06
commit d0d853b252
3 changed files with 28 additions and 3 deletions
@@ -31,6 +31,7 @@ import {
VScrollContentViewNativeComponent,
VScrollViewNativeComponent,
} from '../../../src/private/components/scrollview/VScrollViewNativeComponents';
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
import AnimatedImplementation from '../../Animated/AnimatedImplementation';
import FrameRateLogger from '../../Interaction/FrameRateLogger';
import {findNodeHandle} from '../../ReactNative/RendererProxy';
@@ -1752,8 +1753,11 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
const baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;
const {experimental_endDraggingSensitivityMultiplier, ...otherProps} =
this.props;
const {
experimental_endDraggingSensitivityMultiplier,
maintainVisibleContentPosition,
...otherProps
} = this.props;
const props = {
...otherProps,
alwaysBounceHorizontal,
@@ -1806,6 +1810,10 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
this.props.snapToInterval != null ||
this.props.snapToOffsets != null,
}),
maintainVisibleContentPosition:
ReactNativeFeatureFlags.disableMaintainVisibleContentPosition()
? undefined
: this.props.maintainVisibleContentPosition,
};
const {decelerationRate} = this.props;
@@ -818,6 +818,17 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
disableMaintainVisibleContentPosition: {
defaultValue: false,
metadata: {
dateAdded: '2025-08-26',
description:
'Disable prop maintainVisibleContentPosition in ScrollView',
expectedReleaseValue: false,
purpose: 'experimentation',
},
ossReleaseStage: 'none',
},
enableAccessToHostTreeInFabric: {
defaultValue: true,
metadata: {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bb685c713f0fdecb402fc14a6158d5ae>>
* @generated SignedSource<<276b1579eef10e63c77752017b97985f>>
* @flow strict
* @noformat
*/
@@ -32,6 +32,7 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{
animatedShouldDebounceQueueFlush: Getter<boolean>,
animatedShouldUseSingleOp: Getter<boolean>,
deferFlatListFocusChangeRenderUpdate: Getter<boolean>,
disableMaintainVisibleContentPosition: Getter<boolean>,
enableAccessToHostTreeInFabric: Getter<boolean>,
fixVirtualizeListCollapseWindowSize: Getter<boolean>,
isLayoutAnimationEnabled: Getter<boolean>,
@@ -138,6 +139,11 @@ export const animatedShouldUseSingleOp: Getter<boolean> = createJavaScriptFlagGe
*/
export const deferFlatListFocusChangeRenderUpdate: Getter<boolean> = createJavaScriptFlagGetter('deferFlatListFocusChangeRenderUpdate', false);
/**
* Disable prop maintainVisibleContentPosition in ScrollView
*/
export const disableMaintainVisibleContentPosition: Getter<boolean> = createJavaScriptFlagGetter('disableMaintainVisibleContentPosition', false);
/**
* Enables access to the host tree in Fabric using DOM-compatible APIs.
*/