Marvin Santos Marvin Santos - 1 year ago 262
iOS Question

IONIC - scroll is fired twice when some input is focused on ios

I'm facing an issue with IOS and ionic, if anyone can help with any information about this issue, feel free to share, please.

obs: i'm not using ion-content or any other ionic directive.

THE BUG: i have a form with a lot of inputs.
when the keyboard is open and i click in an input that is not in the middle of the view and is not focused, this input is scrolled to the middle of the view, but then this same input loses the focus and the view is scrolled to the next input that doesn't have focus.

I have tried this workarounds below but no success:

cordova.plugins.Keyboard.disableScroll(true); // <- this code is disabling all the app scroll


Another observation: I put an event listener in all the scroll events in the body, html and window, but this scroll event that happened when input get focus doesn't fire the listener.

Answer Source

I finally find some solution. the mobile devices wait 300ms after the touchend event to then fire the click event, the ionic has an implementation to fix this 300ms delay, and it is made by firing the click event in the touchend event without wait the 300ms and preventing the device to fire the click event after the 300ms. and i think ionic failed to prevent the device to fire the click, causing a ghost click.

the way i solved this: add data-tap-disabled="true" in the elements you don't want to use this 'delay fix' by ionic and the element will respect the normal way to do this, waiting the 300ms then firing the click.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download