Skip to content

Commit 9b5ceab

Browse files
committed
fix(dialogs): android fix for keyboard showing after alert dismiss
1 parent d4467a5 commit 9b5ceab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/dialogs/dialogs.android.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,17 @@ function prepareAndCreateAlertDialog(
171171
return;
172172
}
173173
//ensure we hide any keyboard
174-
const imm = ad.getApplicationContext().getSystemService(android.content.Context.INPUT_METHOD_SERVICE);
175-
imm.toggleSoftInput(android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
176174
onDoneCalled = true;
177175
if (options.view instanceof View) {
178176
Utils.android.dismissSoftInput(options.view.nativeView);
177+
} else {
178+
const activity = (Application.android.foregroundActivity || Application.android.startActivity) as globalAndroid.app.Activity;
179+
const context = ad.getApplicationContext() as android.content.Context;
180+
const view = activity != null ? activity.getCurrentFocus() : null;
181+
if (view) {
182+
const imm = context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as android.view.inputmethod.InputMethodManager;
183+
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
184+
}
179185
}
180186
if (dialog) {
181187
dialog.cancel();

0 commit comments

Comments
 (0)