-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't scroll to input on focus when KeyboardShrinksView enabled #62
Comments
Hi I'm facing the same problem. In my case I have a page with a lot of inputs. When the focus is triggered the page doesn't scroll well. There is any chance to fix this issue or create an work around? |
I have found a workaround. This scrolls the focused input to the top of visible area: document.addEventListener('deviceready', function() {
Keyboard.shrinkView(true)
window.addEventListener('keyboardDidShow', function () {
document.activeElement.scrollIntoView()
})
}) If you want input to be centered instead, use this polyfill. Reasoning behind this solution: i0S Cordova mimics native app by wrapping a web app into UIWebView or WKWebView component. The web view behaves similarly to iOS Safari: when an input is focused and the keyboard appears, the input is centered in the remaining space. That happens without changing viewport.
I'm afraid there is no easy native solution for this. See this comment on ionic issue and this Stack Overflow answer. Web view just wasn't built to contain the whole app and this is the price we have to pay. Provided JavaScript solution is similar to what is advised to do in native iOS apps when keyboard hides input. |
Thanks for your solution. I'll give a try and see how the app behave with this jquery. |
Same here on Android. Tested on Android 8.1.0. |
@leanbalma, does the |
@cjpearson It does, but there's no |
If I start the app with window.Keyboard.shrinkView( false ) it doesnt shrink the view but it also doesnt scroll to the input. The keyboard shows and the page remains exactly the same, nothing scrolls into view, nothing moves etc... |
I have the same Issue on Android - when immersiveMode is set, the shrinkView is somehow disabled. |
When
KeyboardShrinksView
is enabled it breaks the functionality of scrolling to the focused element. When the input is in the bottom part of the window keyboard appears on top of it.Is it a quid pro quo or a bug? If the former, it would be helpful to mention it in a documentation.
The text was updated successfully, but these errors were encountered: