mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-01 06:22:39 +08:00
Add a way to dismiss PopupMenu elements
Summary: In native Android apps, like the YouTube app, context menus are closed when the device orientation changes. In React Native apps instead, when having a [PopupMenu](https://developer.android.com/reference/android/widget/PopupMenu.html) open and rotating the device, the PopupMenu is not dismissed and appears in a wrong position on the screen. This PR exposes a `dismissPopupMenu` method to allow the application to dismiss any open PopupMenu: ```(javascript) UIManager.dismissPopupMenu() ``` Closes https://github.com/facebook/react-native/pull/15636 Differential Revision: D6837663 Pulled By: hramos fbshipit-source-id: 7b0f4f04341129ad45c703a50897e17d93651974
This commit is contained in:
committed by
Facebook Github Bot
parent
6426735e82
commit
353c070be9
@@ -285,6 +285,13 @@ public class UIViewOperationQueue {
|
||||
}
|
||||
}
|
||||
|
||||
private final class DismissPopupMenuOperation implements UIOperation {
|
||||
@Override
|
||||
public void execute() {
|
||||
mNativeViewHierarchyManager.dismissPopupMenu();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A spec for animation operations (add/remove)
|
||||
*/
|
||||
@@ -656,6 +663,10 @@ public class UIViewOperationQueue {
|
||||
mOperations.add(new ShowPopupMenuOperation(reactTag, items, error, success));
|
||||
}
|
||||
|
||||
public void enqueueDismissPopupMenu() {
|
||||
mOperations.add(new DismissPopupMenuOperation());
|
||||
}
|
||||
|
||||
public void enqueueCreateView(
|
||||
ThemedReactContext themedContext,
|
||||
int viewReactTag,
|
||||
|
||||
Reference in New Issue
Block a user