diff --git a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js index 4a004b5ec29..4113e0e1548 100644 --- a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js +++ b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js @@ -122,7 +122,7 @@ const UIManagerJSOverridenAPIs = { * In OSS, the New Architecture will just use the Fabric renderer, which uses * different APIs. */ -const UIManagerJSUnusedAPIs = { +const UIManagerJSUnusedInNewArchAPIs = { createView: ( reactTag: ?number, viewName: string, @@ -155,6 +155,34 @@ const UIManagerJSUnusedAPIs = { }, }; +/** + * Leave unimplemented: These APIs are deprecated in UIManager. We will eventually remove + * them from React Native. + */ +const UIManagerJSDeprecatedPlatformAPIs = Platform.select({ + android: { + // TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75. + showPopupMenu: ( + reactTag: ?number, + items: Array, + error: (error: Object) => void, + success: (event: string, selected?: number) => void, + ): void => { + raiseSoftError( + 'showPopupMenu', + 'Please use the component instead.', + ); + }, + // TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. + dismissPopupMenu: (): void => { + raiseSoftError( + 'dismissPopupMenu', + 'Please use the component instead.', + ); + }, + }, +}); + const UIManagerJSPlatformAPIs = Platform.select({ android: { getConstantsForViewManager: (viewManagerName: string): ?Object => { @@ -232,17 +260,6 @@ const UIManagerJSPlatformAPIs = Platform.select({ FabricUIManager.sendAccessibilityEvent(shadowNode, eventName); }, - showPopupMenu: ( - reactTag: ?number, - items: Array, - error: (error: Object) => void, - success: (event: string, selected?: number) => void, - ): void => { - raiseSoftError('showPopupMenu'); - }, - dismissPopupMenu: (): void => { - raiseSoftError('dismissPopupMenu'); - }, }, ios: { /** @@ -293,8 +310,9 @@ const UIManagerJSPlatformAPIs = Platform.select({ const UIManagerJS: UIManagerJSInterface & {[string]: any} = { ...UIManagerJSOverridenAPIs, + ...UIManagerJSDeprecatedPlatformAPIs, ...UIManagerJSPlatformAPIs, - ...UIManagerJSUnusedAPIs, + ...UIManagerJSUnusedInNewArchAPIs, getViewManagerConfig: (viewManagerName: string): mixed => { if (getUIManagerConstants) { const constants = getUIManagerConstantsCached(); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index 53f31f3cd57..4aa409213b8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -866,12 +866,17 @@ public class NativeViewHierarchyManager { /** * Show a {@link PopupMenu}. * + *

This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75. + * * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this * needs to be the tag of a native view (shadow views can not be anchors) * @param items the menu items as an array of strings * @param success will be called with the position of the selected item as the first argument, or * no arguments if the menu is dismissed */ + @Deprecated public synchronized void showPopupMenu( int reactTag, ReadableArray items, Callback success, Callback error) { UiThreadUtil.assertOnUiThread(); @@ -894,7 +899,14 @@ public class NativeViewHierarchyManager { mPopupMenu.show(); } - /** Dismiss the last opened PopupMenu {@link PopupMenu}. */ + /** + * This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. + * + *

Dismiss the last opened PopupMenu {@link PopupMenu}. + */ + @Deprecated public void dismissPopupMenu() { if (mPopupMenu != null) { mPopupMenu.dismiss(); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 1f527f574b7..0dbe9352b77 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -750,6 +750,10 @@ public class UIImplementation { /** * Show a PopupMenu. * + *

This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75. + * * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this * needs to be the tag of a native view (shadow views can not be anchors) * @param items the menu items as an array of strings @@ -757,6 +761,7 @@ public class UIImplementation { * @param success will be called with the position of the selected item as the first argument, or * no arguments if the menu is dismissed */ + @Deprecated public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) { boolean viewExists = checkOrAssertViewExists(reactTag, "showPopupMenu"); if (!viewExists) { @@ -766,6 +771,8 @@ public class UIImplementation { mOperationsQueue.enqueueShowPopupMenu(reactTag, items, error, success); } + /** TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. */ + @Deprecated public void dismissPopupMenu() { mOperationsQueue.enqueueDismissPopupMenu(); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 793e1121f5b..15a1b425429 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -618,6 +618,10 @@ public class UIManagerModule extends ReactContextBaseJavaModule /** * Show a PopupMenu. * + *

This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75. + * * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this * needs to be the tag of a native view (shadow views can not be anchors) * @param items the menu items as an array of strings @@ -626,11 +630,18 @@ public class UIManagerModule extends ReactContextBaseJavaModule * no arguments if the menu is dismissed */ @ReactMethod + @Deprecated public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) { mUIImplementation.showPopupMenu(reactTag, items, error, success); } + /** + * This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. + */ @ReactMethod + @Deprecated public void dismissPopupMenu() { mUIImplementation.dismissPopupMenu(); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 13e37b48916..2acef25ee15 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -343,6 +343,12 @@ public class UIViewOperationQueue { } } + /** + * This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75. + */ + @Deprecated private final class ShowPopupMenuOperation extends ViewOperation { private final ReadableArray mItems; @@ -362,6 +368,12 @@ public class UIViewOperationQueue { } } + /** + * This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. + */ + @Deprecated private final class DismissPopupMenuOperation implements UIOperation { @Override public void execute() { @@ -703,11 +715,23 @@ public class UIViewOperationQueue { mOperations.add(new UpdateViewExtraData(reactTag, extraData)); } + /** + * This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75. + */ + @Deprecated public void enqueueShowPopupMenu( int reactTag, ReadableArray items, Callback error, Callback success) { mOperations.add(new ShowPopupMenuOperation(reactTag, items, error, success)); } + /** + * This is deprecated, please use the component instead. + * + *

TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. + */ + @Deprecated public void enqueueDismissPopupMenu() { mOperations.add(new DismissPopupMenuOperation()); }