Skip to content
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

bug: ionic 1.0 / Native scrolling for Android makes keyboard hide input field #3727

Closed
mica16 opened this issue May 14, 2015 · 30 comments
Closed
Assignees
Milestone

Comments

@mica16
Copy link

mica16 commented May 14, 2015

Type: bug

Platform: android 4.4 webview

Using ionic 1.0 release and a basic form, when clicking on an input field, the keyboard is opened and hides all the input field. There's no automatic scroll.

It's annoying since the user can't even scroll at all (the screen is locked) to show the field.

@mica16 mica16 changed the title ionic 1.0 / Native scrolling for Android makes keyboard hide input field bug: ionic 1.0 / Native scrolling for Android makes keyboard hide input field May 14, 2015
@perrygovier perrygovier added this to the 1.0.1 milestone May 14, 2015
@lastikas
Copy link

This is really an issue.

The keyboardFocusIn function in keyboard.js disables touch events after the keyboard is shown causing the scroll to 'freeze'
It would be nice not to do that, a possibility I tested was to involve the 'offending' block in a if statement like this:

  if (!ionic.DomUtil.getParentOrSelfWithClass(e.target, 'overflow-scroll')) {
    // any showing part of the document that isn't within the scroll the user
    // could touchmove and cause some ugly changes to the app, so disable
    // any touchmove events while the keyboard is open using e.preventDefault()
    if (window.navigator.msPointerEnabled) {
      document.addEventListener("MSPointerMove", keyboardPreventDefault, false);
    } else {
      document.addEventListener('touchmove', keyboardPreventDefault, false);
    }
  }

But this only solves the frozen scroll problem. There's still the auto scroll to the focused input problem.
This happens because the scrollChildIntoView is assigned to NOOP, which does nothing, as seen in scrollViewNative.js in the __initEventHandlers function

     // should be unnecessary in native scrolling, but keep in case bugs show up
     self.scrollChildIntoView = NOOP;

I'm trying to come up with something but it's kinda tricky

In my opinion this is a major issue that renders native scroll impossible to use in production right now

@felquis
Copy link

felquis commented May 15, 2015

👍 There's also a post in the forum http://forum.ionicframework.com/t/keyboard-issue-with-ionic-v1-0-0/24907

@mathiasmuller4sh
Copy link

Same issue with android L 5.1.1

@Leftyx
Copy link

Leftyx commented May 26, 2015

Same issue here with android 5.1 (Nexus 5).

@tobbbe
Copy link

tobbbe commented Jun 9, 2015

Any solution to this? Will it be fixed in 1.0.1? I dont want to remove native scrolling because its too good :)

@felquis
Copy link

felquis commented Jun 9, 2015

Tobbe which version are you using?
Em 09/06/2015 12:40, "Tobbe" notifications@github.com escreveu:

Any solution to this? Will it be fixed in 1.0.1? I dont want to remove
native scrolling because its too good :)


Reply to this email directly or view it on GitHub
#3727 (comment).

@mica16
Copy link
Author

mica16 commented Jun 9, 2015

@felquis 1.0.0 has the bug

@tobbbe
Copy link

tobbbe commented Jun 9, 2015

Yup I'm on 1.0.0

@mica16
Copy link
Author

mica16 commented Jun 9, 2015

Native scrolling is the best new "feature" in the 1.0.0.
Can't use it because of this critical bug ;)

@felquis
Copy link

felquis commented Jun 9, 2015

Thanks, is this still in the nightly build? :/
Em 09/06/2015 13:13, "Tobbe" notifications@github.com escreveu:

Yup I'm on 1.0.0


Reply to this email directly or view it on GitHub
#3727 (comment).

@perrygovier
Copy link
Contributor

@tlancina, you were looking in to something like this, right?

@tlancina
Copy link
Contributor

Keyboard stuff relies heavily on JS scrolling, if you guys disable the Ionic keyboard code with ionic.keyboard.disable() do you still have issues?

@mica16
Copy link
Author

mica16 commented Jun 15, 2015

@tlancina I will test it right now and let you know :)

@mica16
Copy link
Author

mica16 commented Jun 15, 2015

I tested with ionic.keyboard.disable(); as suggested.
Same result => doesn't solve the issue

For information, I have this too: cordova.plugins.Keyboard.disableScroll(true);

Tested on Ionic 1.0.0 release.

@jacargentina
Copy link

I'have an urgency for this to be solved too: if i can help somehow?

@mica16
Copy link
Author

mica16 commented Jun 15, 2015

@jacargentina I've not found a fix or workaround yet...

@jacargentina
Copy link

Hope this helps: debugging it seems that scrollChildIntoView is invoked, but it's neved executed for a given input

@jacargentina
Copy link

ionic.views.ScrollNative does this:

self.scrollChildIntoView = NOOP;

I'm not aware on the differences on behaviour of having jsScrolling(true) vs. jsScrolling(false), but i think maybe in this case scrollChildIntoView should do the needed work?

@jacargentina
Copy link

#3393 is a duplicate of this

@lastikas
Copy link

I haven't had the time to follow this and the forum's thread for a while now

Please test this fix suggestion, and let me know if it solves the problem without causing others
http://forum.ionicframework.com/t/keyboard-issue-with-ionic-v1-0-0/24907/16?u=lastikas

@jacargentina
Copy link

@lastikas It works, but have 2 little things to make it nicer:

  1. The input is not visible until you press a key after the initial focus
  2. When activating, there is a ugly visual effect which makes all the view to be "crushed" by some ms. and then it goes back to normal

@tlancina
Copy link
Contributor

If someone wants to post a minimal test case on codepen I'll take a look. scrollChildIntoView shouldn't be called if ionic.keyboard.disable() is used, and the web view should just scroll the input into view.

@mica16
Copy link
Author

mica16 commented Jun 15, 2015

@tlancina Actually, when you set ionic.keyboard.disable(), you can now scroll across the form while you have the keyboard opens. That's good but that's not the point of the issue.

What we would like is to prevent an input text (at the bottom of the screen) to be hidden by the keyboard on click.
An automatic scroll should happen so that the input remains visible, so that we can control what we type.

@jacargentina
Copy link

@lastikas I think your code is very close to be the solution to this; if you had some time to fix the 2 observations i made before would be super!

@felquis
Copy link

felquis commented Jun 16, 2015

@tlancina I made a codepen http://codepen.io/felquis/pen/aOyYEZ/ --> to open in your phone http://s.codepen.io/felquis/debug/aOyYEZ

I also created a repository git@github.com:felquis/scroll-bug-3727.git

How to reproduce:
1 - Open app
2 - Scroll I little
3 - Click in any lego item
4 - Here is the form, scroll a little
5 - Now click to focus an input
6 - The scroll is lost, you can't scroll, and the keyboard isn't open.
7 - To be able to scroll, focus the first input and leave the first input
8 - Now you can scroll again

Hope it help you.

@vasumahesh1
Copy link

Hey Guys,

So is this fixed? How can I get these changes on my current project? - Sorry a bit noob here and facing this issue.

@mica16
Copy link
Author

mica16 commented Jun 19, 2015

bower update ionic :)

Make sure your bower.json targets Ionic's master branch.

@felquis
Copy link

felquis commented Jun 19, 2015

I testes it yesterday, there's a 1s delay on Android to start scroll to
input. Something huge happens on touchend, and it take almost 1s to start
scroll.

Also there's some warnings "forced synchronous renderings"

But it's fixed. And works fine.

I tried to save de timeline recorded with DevTools, but looks like there's
a bug I'm unable to save and make a detailed report about performance in
this case.
Em 19/06/2015 09:29, "Michael AZERHAD" notifications@github.com escreveu:

bower install ionic :)

Make sure your bower.json targets master branch.


Reply to this email directly or view it on GitHub
#3727 (comment).

@tlancina
Copy link
Contributor

@felquis if it's an older Android device that's normal, since the actual web view doesn't report its correct size right away (and by right away I mean it takes upwards of 1s on some older devices) once the keyboard has opened. That "something huge" is quite possibly just the keyboard appearing.

Thanks for profiling it, there is so much stuff happening it's a challenge to adjust for the keyboard coming up and still get scrolling at 60fps in a way that will work reliably and quickly across devices.

If you're seeing significant lag on a modern Android device let me know or open a new issue with what device you're seeing it on and a simple codepen reproducing it and I'll take a look.

@felquis
Copy link

felquis commented Jun 19, 2015

Thanks @tlancina, I use Android 4.4.4, Moto X G1, chromium 33. It is probably faster in modern webviews :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants