mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 08:05:34 +00:00
Popups calling error callback instead of crashing if view with passed tagId not found
Summary: The showPopup method has an error callback. For some reason, it is asserting in case the wrong tagId is passed instead of calling the error callback on Android. Pass not existing tagId to showPopup method and make sure it is receiving an error in js instead of crashing in native on Android. [ANDROID] [MINOR] showPopup method calls error callback instead of crashing on errors. Closes https://github.com/facebook/react-native/pull/17550 Differential Revision: D6776014 Pulled By: hramos fbshipit-source-id: 1d97b762818d1591018fd43556eb41c3fb491eb9
This commit is contained in:
parent
70d23e82ad
commit
0c18ec5b9c
@ -724,11 +724,13 @@ public class NativeViewHierarchyManager {
|
||||
* @param success will be called with the position of the selected item as the first argument, or
|
||||
* no arguments if the menu is dismissed
|
||||
*/
|
||||
public synchronized void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
|
||||
public synchronized void showPopupMenu(int reactTag, ReadableArray items, Callback success,
|
||||
Callback error) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
View anchor = mTagsToViews.get(reactTag);
|
||||
if (anchor == null) {
|
||||
throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
|
||||
error.invoke("Can't display popup. Could not find view with tag " + reactTag);
|
||||
return;
|
||||
}
|
||||
PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);
|
||||
|
||||
|
@ -266,20 +266,23 @@ public class UIViewOperationQueue {
|
||||
private final class ShowPopupMenuOperation extends ViewOperation {
|
||||
|
||||
private final ReadableArray mItems;
|
||||
private final Callback mError;
|
||||
private final Callback mSuccess;
|
||||
|
||||
public ShowPopupMenuOperation(
|
||||
int tag,
|
||||
ReadableArray items,
|
||||
Callback error,
|
||||
Callback success) {
|
||||
super(tag);
|
||||
mItems = items;
|
||||
mError = error;
|
||||
mSuccess = success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
mNativeViewHierarchyManager.showPopupMenu(mTag, mItems, mSuccess);
|
||||
mNativeViewHierarchyManager.showPopupMenu(mTag, mItems, mSuccess, mError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -651,7 +654,7 @@ public class UIViewOperationQueue {
|
||||
ReadableArray items,
|
||||
Callback error,
|
||||
Callback success) {
|
||||
mOperations.add(new ShowPopupMenuOperation(reactTag, items, success));
|
||||
mOperations.add(new ShowPopupMenuOperation(reactTag, items, error, success));
|
||||
}
|
||||
|
||||
public void enqueueCreateView(
|
||||
|
Loading…
x
Reference in New Issue
Block a user