[Ionic 4.0.1 iOS pwa] Keyboard blocks input field
See original GitHub issueBug Report
Ionic 4.0.1
Current behavior: Keyboard blocks input on iOS when using Safari or Chrome and as saved to start (pwa). This behaviour does not happen when using Chrome on Android
In the image the password input field that is being edited is not even seen. When using Chrome you are not even able to scroll manually the input field up
Expected behavior: Input should be pushed above keyboard to be able to see what is being typed
Steps to reproduce: Any form in which an input is below the area in which keyboard will be presented
Ionic:
ionic (Ionic CLI) : 4.10.2 (/Users/ale/.npm-global/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.1
@angular-devkit/build-angular : 0.12.4
@angular-devkit/schematics : 7.2.4
@angular/cli : 7.2.4
@ionic/angular-toolkit : 1.3.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : none
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.2, (and 4 other plugins)
System:
NodeJS : v10.14.2 (/usr/local/bin/node)
npm : 6.6.0
OS : macOS Mojave
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
[Ionic 4.0.1 iOS pwa] Keyboard blocks input field · Issue #17419
Current behavior: Keyboard blocks input on iOS when using Safari or Chrome and as saved to start (pwa). ... In the image the...
Read more >angular - Keyboard hides inputs - Ionic 5 - Stack Overflow
I have a problem with my application made with Ionic 5 / angular. What happens is that when I focus on an input...
Read more >Keyboard - Ionic Framework
This guide will provide an introduction to the various tools available for managing the on-screen keyboard in your application. inputmode. The inputmode ...
Read more >Keyboard improvements for Ionic Apps - Ionic Blog
Want the layout of a tel input but just for regular numbers? There's a keyboard for that as well. There are many more...
Read more >Ionic3 – Nikola Brežnjak blog
TL;DR. In this post, I'm going to show you step by step how to build a Cordova plugin for Android that shows a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey guys,
@alejandroquadri @jaco-terbraak
right now I can only speak for Ionic 3 and maybe some team member could explain what’s happening and where in Ionic 4.
Let’s start with HTML5 first (because our team started everything just without the Ionic Input fields and run into some weird problems):
HTML5
Because of the nested structure of
position: absolute
elements, on iOS the native scrolling behavior is really bad / laggy. Therefore are some CSS properties like-webkit-overflow: touch
. And some other scroll optimizing CSS.But if you would normally scroll and have an HTML field, the caret in the focused input field would not update his position while scrolling. That is is a well known bug since October 2014: https://bugs.webkit.org/show_bug.cgi?id=138201
Also if you would focus an input field, when the keyboard would show up, the input field would just stay where it is and the keyboard would overlap.
If you would enable the
keyboard accessory bar
and then would press up or down, the input field would scroll into the view.Then you would also need to calculate on input focus, if it is in the view or not and call
scrollIntoView
(https://developer.mozilla.org/de/docs/Web/API/Element/scrollIntoView)The height was not calculated correctly somehow in the WkWebview, with:
<preference name="KeyboardResizeMode" value="ionic" />
but with
<preference name="KeyboardResizeMode" value="native" />
it was fine.Here is the Objective C code for the plugin:
https://github.com/ionic-team/cordova-plugin-ionic-keyboard/blob/master/src/ios/CDVIonicKeyboard.m#L297
Then the keyboard behavior on some android was messed up.
Ionic 3
The above mentioned optimizations are seen in following element:
.scroll-content
, who is a child element ofion-content
So our scrolling element is
ion-content
. And the elements we want to scroll is ourion-input
. Let’s see into the input.ts:https://github.com/ionic-team/ionic-v3/blob/master/src/components/input/input.ts#L283
So one problem occurred on our side: The ion-content was not injected by dependency injection, because of content projection of custom components, which did have the ion-inputs as parent. Right now there is no other way (as far as I see) as to get these references and register and call everything again yourself.
my-modal.component.ts Parent component, get reference to the Content.
Ion-Input component wrapper component, which gets the reference to the ion-content and has as parent the above component:
form-input-wrapper.component.ts
updateIonInputScrollAsssist method (hacking private things is really bad!)
After this we also encountered another problem, still it was not working with our setup. We used the grid and some other elements which had
position: relative
.Two problems here:
getScrollData
method (I think also problems with offsetTop, but not 100% sure yet) https://github.com/ionic-team/ionic-v3/blob/master/src/components/input/input.ts#L494and
cloneInputComponent
, hiding the caret while scrolling by copying the elements: https://github.com/ionic-team/ionic-v3/blob/master/src/components/input/input.ts#L823Because of
position: relative
theoffsetTop
property is wrong. You would need to calculate the offset of all parents.Ionic 4
Where is the code, solving these issues? Was this solved another way? How was this solved? There were no mentioning about this in ionic 3 or 4 (maybe I overlooked something, please provide me some link).
Content: https://github.com/ionic-team/ionic/blob/master/core/src/components/content/content.tsx
Input: https://github.com/ionic-team/ionic/blob/master/core/src/components/input/input.tsx
I don’t see copying / cloning elements or something like that, as it was before.
@danbucholtz @brandyscarney Our team encountered a lot of problems until we figured out what was happening, can someone please provide some insights? Or if there is a documentation, provide a link for that. We really want to move forward to Ionic 4 in some months, but still there were some other issues. I think they will be also resolved soon. But please don’t let us move to Ionic 4 and encounter again these problems.
I had not the time to set up a repository for Ionic 4 yet, which will verify this, because we want to launch in some month and will stick with Ionic 3 for now until release.
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Thank you for using Ionic!