Skip to content

Commit c631e93

Browse files
alanleedevfacebook-github-bot
authored andcommitted
Remove UIManager.{show|dismiss}PopupMenu (#44096)
Summary: Pull Request resolved: #44096 These Android only APIs have been deprecated and are being removed for 0.75 release. Changelog: [Android][Removed] - UIManager.showPopupMenu() and UIManager.dismissPopupMenu() have been removed Reviewed By: RSNara Differential Revision: D56041827 fbshipit-source-id: e2afebf55860f33d2c8d1887e865adb4dd555e6c
1 parent 4fbc1f2 commit c631e93

10 files changed

Lines changed: 1 addition & 268 deletions

File tree

packages/react-native/Libraries/ReactNative/BridgelessUIManager.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -160,27 +160,7 @@ const UIManagerJSUnusedInNewArchAPIs = {
160160
* them from React Native.
161161
*/
162162
const UIManagerJSDeprecatedPlatformAPIs = Platform.select({
163-
android: {
164-
// TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
165-
showPopupMenu: (
166-
reactTag: number,
167-
items: Array<string>,
168-
error: (error: Object) => void,
169-
success: (event: string, selected?: number) => void,
170-
): void => {
171-
raiseSoftError(
172-
'showPopupMenu',
173-
'Please use the <PopupMenuAndroid /> component instead.',
174-
);
175-
},
176-
// TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
177-
dismissPopupMenu: (): void => {
178-
raiseSoftError(
179-
'dismissPopupMenu',
180-
'Please use the <PopupMenuAndroid /> component instead.',
181-
);
182-
},
183-
},
163+
android: {},
184164
});
185165

186166
const UIManagerJSPlatformAPIs = Platform.select({

packages/react-native/Libraries/ReactNative/UIManager.d.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,6 @@ export interface UIManagerStatic {
8989
| ((value: boolean) => void)
9090
| undefined;
9191

92-
/**
93-
* Used to display an Android PopupMenu. If a menu item is pressed, the success callback will
94-
* be called with the following arguments:
95-
*
96-
* - item - the menu item.
97-
* - index - index of the pressed item in array. Returns `undefined` if cancelled.
98-
*
99-
* To obtain a native node handle for a component, you can use
100-
* `React.findNodeHandle(component)`.
101-
*
102-
* Note that this works only on Android
103-
*/
104-
showPopupMenu?:
105-
| ((
106-
node: number,
107-
items: string[],
108-
error: () => void /* currently unused */,
109-
success: (item: string, index: number | undefined) => void,
110-
) => void)
111-
| undefined;
112-
11392
getViewManagerConfig: (name: string) => {
11493
Commands: {[key: string]: number};
11594
};

packages/react-native/Libraries/ReactNative/UIManagerProperties.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ module.exports = [
3030
'clearJSResponder',
3131
'configureNextLayoutAnimation',
3232
'createView',
33-
'dismissPopupMenu',
3433
'dispatchViewManagerCommand',
3534
'findSubviewIn',
3635
'getConstantsForViewManager',
@@ -45,10 +44,8 @@ module.exports = [
4544
'setChildren',
4645
'setJSResponder',
4746
'setLayoutAnimationEnabledExperimental',
48-
'showPopupMenu',
4947
'updateView',
5048
'viewIsDescendantOf',
51-
'PopupMenu',
5249
'LazyViewManagersEnabled',
5350
'ViewManagerNames',
5451
'StyleConstants',

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4257,7 +4257,6 @@ public class com/facebook/react/uimanager/NativeViewHierarchyManager {
42574257
protected final fun addRootViewGroup (ILandroid/view/View;)V
42584258
public fun clearJSResponder ()V
42594259
public fun createView (Lcom/facebook/react/uimanager/ThemedReactContext;ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
4260-
public fun dismissPopupMenu ()V
42614260
public fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
42624261
public fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
42634262
protected fun dropView (Landroid/view/View;)V
@@ -4274,7 +4273,6 @@ public class com/facebook/react/uimanager/NativeViewHierarchyManager {
42744273
public fun setChildren (ILcom/facebook/react/bridge/ReadableArray;)V
42754274
public fun setJSResponder (IIZ)V
42764275
public fun setLayoutAnimationEnabled (Z)V
4277-
public fun showPopupMenu (ILcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
42784276
public fun updateInstanceHandle (IJ)V
42794277
public fun updateLayout (IIIIII)V
42804278
public fun updateProperties (ILcom/facebook/react/uimanager/ReactStylesDiffMap;)V
@@ -4989,7 +4987,6 @@ public class com/facebook/react/uimanager/UIImplementation {
49894987
protected fun createRootShadowNode ()Lcom/facebook/react/uimanager/ReactShadowNode;
49904988
protected fun createShadowNode (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactShadowNode;
49914989
public fun createView (ILjava/lang/String;ILcom/facebook/react/bridge/ReadableMap;)V
4992-
public fun dismissPopupMenu ()V
49934990
public fun dispatchViewManagerCommand (IILcom/facebook/react/bridge/ReadableArray;)V
49944991
public fun dispatchViewManagerCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
49954992
public fun dispatchViewUpdates (I)V
@@ -5025,7 +5022,6 @@ public class com/facebook/react/uimanager/UIImplementation {
50255022
public fun setLayoutUpdateListener (Lcom/facebook/react/uimanager/UIImplementation$LayoutUpdateListener;)V
50265023
public fun setViewHierarchyUpdateDebugListener (Lcom/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener;)V
50275024
public fun setViewLocalData (ILjava/lang/Object;)V
5028-
public fun showPopupMenu (ILcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
50295025
public fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/uimanager/ReactStylesDiffMap;)V
50305026
public fun updateNodeSize (III)V
50315027
public fun updateRootView (III)V
@@ -5069,7 +5065,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
50695065
public fun configureNextLayoutAnimation (Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
50705066
public static fun createConstants (Ljava/util/List;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
50715067
public fun createView (ILjava/lang/String;ILcom/facebook/react/bridge/ReadableMap;)V
5072-
public fun dismissPopupMenu ()V
50735068
public fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
50745069
public fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
50755070
public fun dispatchViewManagerCommand (ILcom/facebook/react/bridge/Dynamic;Lcom/facebook/react/bridge/ReadableArray;)V
@@ -5113,7 +5108,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
51135108
public fun setLayoutAnimationEnabledExperimental (Z)V
51145109
public fun setViewHierarchyUpdateDebugListener (Lcom/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener;)V
51155110
public fun setViewLocalData (ILjava/lang/Object;)V
5116-
public fun showPopupMenu (ILcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
51175111
public fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
51185112
public fun stopSurface (I)V
51195113
public fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/bridge/ReadableMap;)V
@@ -5144,7 +5138,6 @@ public class com/facebook/react/uimanager/UIViewOperationQueue {
51445138
public fun enqueueClearJSResponder ()V
51455139
public fun enqueueConfigureLayoutAnimation (Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;)V
51465140
public fun enqueueCreateView (Lcom/facebook/react/uimanager/ThemedReactContext;ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
5147-
public fun enqueueDismissPopupMenu ()V
51485141
public fun enqueueDispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
51495142
public fun enqueueDispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
51505143
public fun enqueueFindTargetForTouch (IFFLcom/facebook/react/bridge/Callback;)V
@@ -5157,7 +5150,6 @@ public class com/facebook/react/uimanager/UIViewOperationQueue {
51575150
public fun enqueueSetChildren (ILcom/facebook/react/bridge/ReadableArray;)V
51585151
public fun enqueueSetJSResponder (IIZ)V
51595152
public fun enqueueSetLayoutAnimationEnabled (Z)V
5160-
public fun enqueueShowPopupMenu (ILcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
51615153
public fun enqueueUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
51625154
protected fun enqueueUIOperation (Lcom/facebook/react/uimanager/UIViewOperationQueue$UIOperation;)V
51635155
public fun enqueueUpdateExtraData (ILjava/lang/Object;)V

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@
1212
import android.graphics.RectF;
1313
import android.util.SparseArray;
1414
import android.util.SparseBooleanArray;
15-
import android.view.Menu;
16-
import android.view.MenuItem;
1715
import android.view.View;
1816
import android.view.ViewGroup;
1917
import android.view.ViewParent;
20-
import android.widget.PopupMenu;
2118
import androidx.annotation.Nullable;
2219
import com.facebook.common.logging.FLog;
2320
import com.facebook.react.R;
@@ -81,7 +78,6 @@ public class NativeViewHierarchyManager {
8178
private final RectF mBoundingBox = new RectF();
8279

8380
private boolean mLayoutAnimationEnabled;
84-
private PopupMenu mPopupMenu;
8581
private HashMap<Integer, Set<Integer>> mPendingDeletionsForTag;
8682

8783
public NativeViewHierarchyManager(ViewManagerRegistry viewManagers) {
@@ -862,85 +858,6 @@ public synchronized void dispatchCommand(
862858
viewManager.receiveCommand(view, commandId, args);
863859
}
864860

865-
/**
866-
* Show a {@link PopupMenu}.
867-
*
868-
* <p>This is deprecated, please use the <PopupMenuAndroid /> component instead.
869-
*
870-
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
871-
*
872-
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
873-
* needs to be the tag of a native view (shadow views can not be anchors)
874-
* @param items the menu items as an array of strings
875-
* @param success will be called with the position of the selected item as the first argument, or
876-
* no arguments if the menu is dismissed
877-
*/
878-
@Deprecated
879-
public synchronized void showPopupMenu(
880-
int reactTag, ReadableArray items, Callback success, Callback error) {
881-
UiThreadUtil.assertOnUiThread();
882-
View anchor = mTagsToViews.get(reactTag);
883-
if (anchor == null) {
884-
error.invoke("Can't display popup. Could not find view with tag " + reactTag);
885-
return;
886-
}
887-
mPopupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);
888-
889-
Menu menu = mPopupMenu.getMenu();
890-
for (int i = 0; i < items.size(); i++) {
891-
menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
892-
}
893-
894-
PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
895-
mPopupMenu.setOnMenuItemClickListener(handler);
896-
mPopupMenu.setOnDismissListener(handler);
897-
898-
mPopupMenu.show();
899-
}
900-
901-
/**
902-
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
903-
*
904-
* <p>TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
905-
*
906-
* <p>Dismiss the last opened PopupMenu {@link PopupMenu}.
907-
*/
908-
@Deprecated
909-
public void dismissPopupMenu() {
910-
if (mPopupMenu != null) {
911-
mPopupMenu.dismiss();
912-
}
913-
}
914-
915-
private static class PopupMenuCallbackHandler
916-
implements PopupMenu.OnMenuItemClickListener, PopupMenu.OnDismissListener {
917-
918-
final Callback mSuccess;
919-
boolean mConsumed = false;
920-
921-
private PopupMenuCallbackHandler(Callback success) {
922-
mSuccess = success;
923-
}
924-
925-
@Override
926-
public void onDismiss(PopupMenu menu) {
927-
if (!mConsumed) {
928-
mSuccess.invoke(UIManagerModuleConstants.ACTION_DISMISSED);
929-
mConsumed = true;
930-
}
931-
}
932-
933-
@Override
934-
public boolean onMenuItemClick(MenuItem item) {
935-
if (!mConsumed) {
936-
mSuccess.invoke(UIManagerModuleConstants.ACTION_ITEM_SELECTED, item.getOrder());
937-
mConsumed = true;
938-
return true;
939-
}
940-
return false;
941-
}
942-
}
943-
944861
/**
945862
* @return Themed React context for view with a given {@param reactTag} - it gets the context
946863
* directly from the view using {@link View#getContext}.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -741,36 +741,6 @@ public void dispatchViewManagerCommand(
741741
mOperationsQueue.enqueueDispatchCommand(reactTag, commandId, commandArgs);
742742
}
743743

744-
/**
745-
* Show a PopupMenu.
746-
*
747-
* <p>This is deprecated, please use the <PopupMenuAndroid /> component instead.
748-
*
749-
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
750-
*
751-
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
752-
* needs to be the tag of a native view (shadow views can not be anchors)
753-
* @param items the menu items as an array of strings
754-
* @param error will be called if there is an error displaying the menu
755-
* @param success will be called with the position of the selected item as the first argument, or
756-
* no arguments if the menu is dismissed
757-
*/
758-
@Deprecated
759-
public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) {
760-
boolean viewExists = checkOrAssertViewExists(reactTag, "showPopupMenu");
761-
if (!viewExists) {
762-
return;
763-
}
764-
765-
mOperationsQueue.enqueueShowPopupMenu(reactTag, items, error, success);
766-
}
767-
768-
/** TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. */
769-
@Deprecated
770-
public void dismissPopupMenu() {
771-
mOperationsQueue.enqueueDismissPopupMenu();
772-
}
773-
774744
public void sendAccessibilityEvent(int tag, int eventType) {
775745
mOperationsQueue.enqueueSendAccessibilityEvent(tag, eventType);
776746
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -615,37 +615,6 @@ public void dispatchCommand(int reactTag, String commandId, @Nullable ReadableAr
615615
mUIImplementation.dispatchViewManagerCommand(reactTag, commandId, commandArgs);
616616
}
617617

618-
/**
619-
* Show a PopupMenu.
620-
*
621-
* <p>This is deprecated, please use the <PopupMenuAndroid /> component instead.
622-
*
623-
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
624-
*
625-
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
626-
* needs to be the tag of a native view (shadow views can not be anchors)
627-
* @param items the menu items as an array of strings
628-
* @param error will be called if there is an error displaying the menu
629-
* @param success will be called with the position of the selected item as the first argument, or
630-
* no arguments if the menu is dismissed
631-
*/
632-
@ReactMethod
633-
@Deprecated
634-
public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) {
635-
mUIImplementation.showPopupMenu(reactTag, items, error, success);
636-
}
637-
638-
/**
639-
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
640-
*
641-
* <p>TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
642-
*/
643-
@ReactMethod
644-
@Deprecated
645-
public void dismissPopupMenu() {
646-
mUIImplementation.dismissPopupMenu();
647-
}
648-
649618
/**
650619
* LayoutAnimation API on Android is currently experimental. Therefore, it needs to be enabled
651620
* explicitly in order to avoid regression in existing application written for iOS using this API.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ public static Map<String, Object> getConstants() {
104104
"unspecified",
105105
PointerEvents.AUTO.ordinal())));
106106

107-
constants.put(
108-
"PopupMenu",
109-
MapBuilder.of(
110-
ACTION_DISMISSED, ACTION_DISMISSED, ACTION_ITEM_SELECTED, ACTION_ITEM_SELECTED));
111-
112107
constants.put(
113108
"AccessibilityEventTypes",
114109
MapBuilder.of(

0 commit comments

Comments
 (0)