ionic-team / ionic-plugin-keyboard

Ionic Keyboard Plugin for Cordova
Apache License 2.0
611 stars 278 forks source link

Keyboard reopens after close #288

Closed ghost closed 6 years ago

ghost commented 6 years ago

I call Keyboard.close() in order to close the keyboard programmatically on iOS but as soon as I tap somewhere else on the screen it reopens. Any opinions?

ChiHinTse commented 6 years ago

also facing the same problem

Baadier-Sydow commented 6 years ago

Has this been resolved?

I'm still facing the same issue.

On my end, I can reproduce it by opening the keyboard on an input field and then navigating away from the page.

I tried to tap into the ionViewWillLeave() lifecycle event to call Keyboard.close() but it still pops up continuously on each touch event.

It doesn't do this on Android and I have hideKeyboardAccessoryBar(false) set on iOS.

ghost commented 6 years ago

Are you facing this issue in an iframe?

Baadier-Sydow commented 6 years ago

That is correct.

I'm getting this issue with the Stripe.js integration which injects an iframe into the page.

ghost commented 6 years ago

I managed to solve this problem like this: I simulated a back button on the iframe(keyboard closes when tapping on iframe input controls), on which I've registered an event. This event triggers an emit event(check them if you haven't seen them on javascript) which is listened to by the Ionic application. When the event is triggered in the Ionic application I do a back programmatically. This was my situation, hope this helps!

Baadier-Sydow commented 6 years ago

I got mine working too but in a different way. I ended up using a hidden input that I would put focus into when the page was being removed and it solved my issue. More details here.