[BUG] Side menu doesn't open on Swipe if the keyboard has been displayed (Android)


#1

Hi everyone,

UPDATE

It seems like the issue is actually pretty easy to reproduce. But it does not happen in browsers. However I managed to reproduce it 100% of the time on Android (Smartphone and Emulator (GenyMotion), Nexus 5, Android 5.1).

I have an input field on my home screen where user can type things to search. This view does not contain a side menu.
I put a direct link (with ui-sref) to my second view containing a side menu (this is the buggy one…).
=> If I click in the input, it makes the keyboard appear. Then when I go to my second view (the one with the side menu) using the ui-sref link, the SWIPE “on drag” does not work.
=> If I directly click the ui-sref link ( = the keyboard has not been displayed), then the side menu can be open by swiping/dragging.

I tried with both clicking with open keyboard and closed/hidden keyboard. It “disables” the swipe/drag all the time.

Did anyone encounter a similar issue?

Thanks!

Regards


#3

Hi everyone,

Some news about it after many configurations tested:

  • With enable-menu-with-back-views (ion-side-menu) set to true, the swipe doesn’t work on the second view after a call to change of state.
  • With enable-menu-with-back-views set to set to false, the swipe does work on the second view, but doesn’t anymore once a sub-view has been displayed.

It seems that the issue comes from the user of the function keyboardPreventDefault(), which, by using preventDefault, makes the result of “isDraggableTarget” false. As the following part of the test is false: !e.gesture.srcEvent.defaultPrevented.

return ($scope.dragContent || self.isOpen()) &&
  dragIsWithinBounds &&

  !e.gesture.srcEvent.defaultPrevented &&
  
  menuEnabled &&
  !e.target.tagName.match(/input|textarea|select|object|embed/i) &&
  !e.target.isContentEditable &&
  !(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-scroll') == 'true');

The code of the method (from ionic framework) is:

/**
 * Event for 'touchmove' or 'MSPointerMove'. Prevents native scrolling on
 * elements outside the scroll view while the keyboard is open.
 */
function keyboardPreventDefault(e) {
  if (e.target.tagName !== 'TEXTAREA') {
    e.preventDefault();
  }
}

Here’s a quick workaround (which I don’t like, as I’d like to avoid modifying ionic’s code):

/**
 * Event for 'touchmove' or 'MSPointerMove'. Prevents native scrolling on
 * elements outside the scroll view while the keyboard is open.
 */
function keyboardPreventDefault(e) {
  if (e.target.tagName !== 'TEXTAREA' && ionic.keyboard.isOpen) {
    e.preventDefault();
  }
}

As the method is useful only if the keyboard is open (cf its JSDoc), I guess it’s full of sense to test ionic.keyboard.isOpen before calling e.preventDefault().

EDIT - I creatd a pull request here: https://github.com/driftyco/ionic/pull/4469


#4

Hi,

Sorry for bumping the thread again.

I was wondering at which frequency the pull requests were accepted (or rejected)?

Thanks.