0

How do I disable the created alert using alert controller from automatically focusing onto the input field with the keyboard being displayed?

let alert = self.alertCtrl.create({
        title: 'Login',
        inputs: [
          {
            name: 'location_code',
            placeholder: 'Location Code',
          },
          {
            name: 'password',
            placeholder: 'Password',
            type: 'password'
          }
        ],
        buttons: [
          {
            text: 'Cancel',
            role: 'cancel',
            handler: data => {
              console.log('Cancel clicked');
            }
          },
          {
            text: 'Login',
            handler: data => {
                 console.log("Handling Login On Click")
              });
            }
          }
        ]
      });
      alert.present();

Attempted Solution which didn't result in any change

this.alertController.create(
...
)
.present({
    keyboardClose: true
});
Yeo Bryan
  • 331
  • 4
  • 24

1 Answers1

0

In ionic 3 there was no keyboardClose option (see v3 vs v5), so you probably need to manually remove focus, eg like this:

let alert = self.alertCtrl.create({...});
alert.present().then(() => {
  (<any>document.querySelector('ion-alert input')).blur();
})
sean
  • 188
  • 3