diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java index 318594c2eb5574..561b96d13baefb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java @@ -293,14 +293,11 @@ protected void showOrUpdate() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP) { - // We need to stop the BACK button from closing the dialog by default so we capture - // that - // event and instead inform JS so that it can make the decision as to whether or not - // to - // allow the back button to close the dialog. If it chooses to, it can just set - // visible - // to false on the Modal and the Modal will go away - if (keyCode == KeyEvent.KEYCODE_BACK) { + // We need to stop the BACK button and ESCAPE key from closing the dialog by default + // so we capture that event and instead inform JS so that it can make the decision as + // to whether or not to allow the back/escape key to close the dialog. If it chooses + // to, it can just set visible to false on the Modal and the Modal will go away + if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE) { Assertions.assertNotNull( mOnRequestCloseListener, "setOnRequestCloseListener must be called by the manager"); @@ -308,9 +305,8 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { return true; } else { // We redirect the rest of the key events to the current activity, since the - // activity - // expects to receive those events and react to them, ie. in the case of the dev - // menu + // activity expects to receive those events and react to them, ie. in the case of + // the dev menu Activity currentActivity = ((ReactContext) getContext()).getCurrentActivity(); if (currentActivity != null) { return currentActivity.onKeyUp(keyCode, event);