Skip to content

Commit c722b59

Browse files
author
farfromrefug
committed
fix(dialogs): autoFocus not working
1 parent fecf7a6 commit c722b59

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/dialogs/dialogs.android.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt
6666
moduleName: options.view as string
6767
});
6868
if (view.parent) {
69-
view.parent._removeView(view)
69+
view.parent._removeView(view);
7070
}
7171
view.cssClasses.add(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS);
7272
const modalRootViewCssClasses = CSSUtils.getSystemCssClasses();
@@ -475,6 +475,13 @@ export function prompt(arg: any): Promise<PromptResult> {
475475

476476
showDialog(dlg, options);
477477
if (options.autoFocus) {
478+
// seems not to work if called too soon so we call it again
479+
// once the view is focused and ready
480+
textField.once('focus', () => {
481+
setTimeout(() => {
482+
textField.requestFocus();
483+
}, 100);
484+
});
478485
textField.requestFocus();
479486
}
480487
} catch (ex) {
@@ -559,6 +566,13 @@ export function login(arg: any): Promise<LoginResult> {
559566
);
560567
showDialog(dlg, options);
561568
if (options.autoFocus) {
569+
// seems not to work if called too soon so we call it again
570+
// once the view is focused and ready
571+
userNameTextField.once('focus', () => {
572+
setTimeout(() => {
573+
userNameTextField.requestFocus();
574+
}, 100);
575+
});
562576
userNameTextField.requestFocus();
563577
}
564578
} catch (ex) {

0 commit comments

Comments
 (0)