From 998c71487d13b199b926bd4811c8f86a98636369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 30 Sep 2026 06:10:13 -0700 Subject: [PATCH] Remove unstable_getScrollParent Summary: Remove the unstable_getScrollParent export and its private implementation from React Native. Scroll-parent discovery depends on application-specific scrollability semantics and should be implemented in userland. Changelog: [General][Removed] - Remove unstable_getScrollParent. Implement scroll-parent discovery in userland instead. Differential Revision: D122555525 --- packages/eslint-plugin-react-native/utils.js | 4 -- packages/react-native/index.js | 4 -- packages/react-native/index.js.flow | 1 - .../virtualcollection/dom/getScrollParent.js | 43 ------------------- .../virtualcollection/dom/isScrollableNode.js | 22 ---------- 5 files changed, 74 deletions(-) delete mode 100644 packages/react-native/src/private/components/virtualcollection/dom/getScrollParent.js delete mode 100644 packages/react-native/src/private/components/virtualcollection/dom/isScrollableNode.js diff --git a/packages/eslint-plugin-react-native/utils.js b/packages/eslint-plugin-react-native/utils.js index be51ad8d14cf..12f0f3c2c417 100644 --- a/packages/eslint-plugin-react-native/utils.js +++ b/packages/eslint-plugin-react-native/utils.js @@ -641,10 +641,6 @@ const publicAPIMapping = { default: null, types: null, }, - 'src/private/components/virtualcollection/dom/getScrollParent': { - default: null, - types: null, - }, 'src/private/components/virtualcollection/row/VirtualRow': { default: null, types: null, diff --git a/packages/react-native/index.js b/packages/react-native/index.js index 80fb9723e4f9..08c71232d66a 100644 --- a/packages/react-native/index.js +++ b/packages/react-native/index.js @@ -200,10 +200,6 @@ module.exports = { return require('./src/private/components/virtualcollection/row/VirtualRow') .default; }, - get unstable_getScrollParent() { - return require('./src/private/components/virtualcollection/dom/getScrollParent') - .default; - }, get unstable_DEFAULT_INITIAL_NUM_TO_RENDER() { return require('./src/private/components/virtualcollection/FlingConstants') .DEFAULT_INITIAL_NUM_TO_RENDER; diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index 26bdee2353d7..1886486c571c 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -530,7 +530,6 @@ export type { export {default as unstable_VirtualColumn} from './src/private/components/virtualcollection/column/VirtualColumn'; export {default as unstable_VirtualColumnGenerator} from './src/private/components/virtualcollection/column/VirtualColumnGenerator'; export {default as unstable_VirtualRow} from './src/private/components/virtualcollection/row/VirtualRow'; -export {default as unstable_getScrollParent} from './src/private/components/virtualcollection/dom/getScrollParent'; export {DEFAULT_INITIAL_NUM_TO_RENDER as unstable_DEFAULT_INITIAL_NUM_TO_RENDER} from './src/private/components/virtualcollection/FlingConstants'; // #endregion diff --git a/packages/react-native/src/private/components/virtualcollection/dom/getScrollParent.js b/packages/react-native/src/private/components/virtualcollection/dom/getScrollParent.js deleted file mode 100644 index 21250997af66..000000000000 --- a/packages/react-native/src/private/components/virtualcollection/dom/getScrollParent.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -import ReactNativeElement from '../../../webapis/dom/nodes/ReactNativeElement'; -import isScrollableNode from './isScrollableNode'; - -/** - * Finds the nearest ancestor of the supplied node that is a scrollable node. - * - * Unlike the web-equivalent function, the return type is nullable because the - * root is not an implicitly scrollable node. - */ -export default function getScrollParent( - node: ReactNativeElement, -): ReactNativeElement | null { - let element: ReactNativeElement | null = node; - while (element != null) { - if (isScrollableNode(element)) { - return element; - } - const parent = element.parentElement; - // Currently, the only subclass of `ReadOnlyNode` is `ReactNativeElement`. - if (parent instanceof ReactNativeElement || parent == null) { - element = parent; - } else { - console.error( - 'Expected `element.parentElement` to be `?ReactNativeElement`, got: %s', - parent, - ); - element = null; - } - // So this is equivalent to a null check with type safety. - element = parent instanceof ReactNativeElement ? parent : null; - } - return null; -} diff --git a/packages/react-native/src/private/components/virtualcollection/dom/isScrollableNode.js b/packages/react-native/src/private/components/virtualcollection/dom/isScrollableNode.js deleted file mode 100644 index 891ed0a3cd90..000000000000 --- a/packages/react-native/src/private/components/virtualcollection/dom/isScrollableNode.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -import type ReactNativeElement from '../../../webapis/dom/nodes/ReactNativeElement'; - -/** - * Checks whether the supplied node is a scrollable node, ignoring whether - * there is sufficient content to scroll or whether scrolling is disabled. - */ -export default function isScrollableNode(node: ReactNativeElement): boolean { - // Applies for vertical and horizontal `ScrollView` on both Android and iOS. - // The content container might have a different `nodeName`, but its parent - // always has this `nodeName`. - return node.nodeName === 'RN:ScrollView'; -}