Hi guys. So currently i’m working on an app that includes a messenger-like chat component, and i’ve hit a brick wall (probably counting something like 10+ hours working on this problem alone).
If you open messenger, you will see that after you tap the message bar, and type a message:
- The keyboard stays up, doesn’t flash or disappear.
- The focus is still on the text input.
- If you scroll the messages area up or down, the keyboard stays in position and the input stays focused.
I’ve been through countless threads on Github issues about this, many closed off (in my opinion some prematurely) about keeping the keyboard open, some are saying:
- Call
preventDefault()
on the$event
from either aclick
ormousedown
event - This hasn’t worked so far for me, the keyboard still dismisses and the focus comes away from the input. - Call
.setFocus()
on aViewChild()
reference to the input itself - when i do this, i either get told that the input’s ViewChild objectis not an object
, or that thesetFocus()
method does not exist. Also, i’ve tried callingthis.mainInput.nativeElement.focus()
, and that also fails. - I have the
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
preference in myconfig.xml
- it doesn’t affect anything. - I’ve also tried manually adding the event listeners as per this github thread: https://github.com/ionic-team/ionic-plugin-keyboard/issues/81#issuecomment-318948443 - but no luck, the listeners never seem to bind and clicking the button dismisses the keyboard and doesn’t fire any of the listeners at all - in fact if you
console.log
the element itself (this.mainInput
), it outputsnull
.
I would love it if anyone has any advice for how to achieve this, as at this point i’m not even sure it’s possible with Ionic and may need to move my client to react native (which will cost me money, and delay the delivery to the client).
Any help is really appreciated guys - i may even be able to pay for some consulting time for this.
I’d also really appreciate it if the Core devs could let me know if it’s possible at all!
Many many thanks.
Dan.