ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

select gets tap, when below Ionic Popup's Ok Button

Open 1aishwaryasharma opened this issue 12 years ago • 10 comments

Issue - If a popup's 'OK' button is right above/over an underlying select option, then after selecting the 'OK' button of the popup, the select also gets called.

Sample Code - https://github.com/Dbms/Ionic_Sample_2

Steps to reproduce issue -

  1. Click the button 'Do Something!' on the top left. You get an ionic popup.
  2. Click the OK button on the popup, the underlying select option also gets clicked.

Note -

  1. Use iPhone 3.5 inch simulator, in which case the OK button comes properly over a select option.
  2. If instead of select, there is a button below, then the button click does not occur (which should be the behaviour)

1aishwaryasharma avatar Jun 09 '14 07:06 1aishwaryasharma

Thank @Dbms. It looks like the the e.preventDefault() in tapClickGateKeeper isn't working as expected. Firing an e.target.blur() immediately after it mostly fixed the problem, but the select window starts to slide up for a fraction of a second. I'll keep investigating.

perrygovier avatar Jun 09 '14 22:06 perrygovier

A little more research, tapTouchStart is where we need an e.preventDefault() to properly stop the focus from ever happening. Currently it's fired on text inputs because ionic.tap.isLabelWithTextInput(e.target) returns true in that event. I believe we need a method to prevent these second touch/click events that fire in the same location a split second later. Calling preventDefault on select elements in that event should suffice for this case though.

perrygovier avatar Jun 09 '14 22:06 perrygovier

What's happening is that Ionic is simulating the click for the button so that it happens immediately after touchend (to remove the 300ms delay). However, iOS is also firing off the actual click 300ms later. By the time iOS fires off its click, the popup has gone away and what is showing is the select element in the same location.

Preventing any second clicks in the same location is what Ionic originally used to remove the 300ms, but it proved to cause too many issues, and it caused too large of delay between clicks when clicking fast in the same location.

This issue is the same which actionsheet and modals have because those services also remove themselves from the view when its done, but the native click 300ms later causes issues when clicking the content underneath the actionsheet/modal/popup.

We should verify if its only a select element issue, or if it also tries to focus in on text inputs, or tries clicking buttons in the same location. In the end the best method to prevent this is to not remove the backdrop immediately, but rather 400ms later, so that its pointer-events:none can block any upcoming clicks which the browser may send later.

Also, be sure to update your code to use the latest Ionic version.

adamdbradley avatar Jun 10 '14 02:06 adamdbradley

@perrygovier Thanks for taking this up!! @adamdbradley If I remember correctly, I checked with the Beta 6 of Ionic also, the issue is there.

Just to correct myself in the Problem Statement, it is not specifically 'OK' button of the PopUp, it happens on the 'Cancel' also - if the underlying select option overlaps with the Cancel button..

1aishwaryasharma avatar Jun 10 '14 18:06 1aishwaryasharma

Ok, some more investigation.

Text inputs will also gain focus, but buttons do not. I get a clickPrevent BUTTON in my logs when the button is behind the button that closes the modal.

Since we're creating our own click handlers, what if we added an extra blocking parameter to click events? So most buttons would not get this, but when our click event triggers an animation that could reveal a new input element, we provide a param that blocks click events for 400ms?

perrygovier avatar Jun 10 '14 20:06 perrygovier

@adamdbradley I have changed some code in the ionic.bundle.js as you had suggested - to increase the time after which the backdrop is removed

function release() {
    if ( (--backdropHolds) === 0 ) {
      el.removeClass('active');
      setTimeout(function() {
        !backdropHolds && el.removeClass('visible');
      }, 400);
    }
  }

This seems to correct the issue for now, at least on the tests on the iPhone Simulator. Is this correct, or were you implying something else ?

1aishwaryasharma avatar Jun 12 '14 10:06 1aishwaryasharma

@Dbms, @adamdbradley This issues occurs with the actionsheet as well. And though increasing the time from 100 to 400 after removal of the backdrop seem to work correctly for the popup, it does not for the actionsheet. Any more thought on this?

And is this issue not similar to: https://github.com/driftyco/ionic/issues/1536 ?

marioese avatar Jun 12 '14 14:06 marioese

@marioese Definitely seems similar to #1536. The Ionic team would be better to tell you the solution for actionsheet though.

1aishwaryasharma avatar Jun 13 '14 21:06 1aishwaryasharma

This should be fixed from: https://github.com/driftyco/ionic/commit/20d567f81c1dcdb537d7acf83a7afae7961e8286

adamdbradley avatar Sep 18 '14 02:09 adamdbradley

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. 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.

ionitron-bot[bot] avatar Sep 06 '18 15:09 ionitron-bot[bot]