ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

weird behavior in iOS Safari

Open jesuslpm opened this issue 11 years ago • 16 comments

Hello,

ui-select works great on desktop, but in iOS Safare I have experienced weird behavior. When you clik on the control some ramdom item is selected, the keyboard is not shown. If then you select one item tapping on it, the keyboard is suddenly shown and the wrong item is selected. If instead of tapping on an item, you tap on the control again, the keyboard is shown, and all works as expected.

jesuslpm avatar Jan 22 '15 15:01 jesuslpm

You can see this behavior on the demo page, testing it with iPad mini iOs version 8.1.2

http://plnkr.co/edit/a3KlK8dKH3wwiiksDSn2?p=preview

jesuslpm avatar Jan 22 '15 15:01 jesuslpm

Same issue here on iPad mini 2 & iPhone 4/4S

aziule avatar Feb 13 '15 14:02 aziule

Is there a fix for this issue yet? i am also facing this issue.

siva-I avatar Feb 25 '15 00:02 siva-I

+1

sinxwal avatar Mar 16 '15 09:03 sinxwal

+1

MalikAbed avatar Mar 24 '15 16:03 MalikAbed

+1

dallasclark avatar Apr 15 '15 22:04 dallasclark

can confirm this too

yeehahboogie avatar Apr 24 '15 03:04 yeehahboogie

Have somebody found how to fix it? Any forked project / quickfix?

aziule avatar Apr 27 '15 12:04 aziule

+1

trouseredApe avatar May 11 '15 14:05 trouseredApe

The reason of the bug is that iOS safari doesn't allow to set focus from functions which wasn't the result of user's interaction. Specifically the first function in call stack must be some sort of reaction on 'click', 'touchend',.. events. Some details here. Quick fix is to remove timeout in this code: Replace

$timeout(function() {
  ctrl.search = initSearchValue || ctrl.search;
  ctrl.searchInput[0].focus();
});

with

  ctrl.search = initSearchValue || ctrl.search;
  ctrl.searchInput[0].focus();

Timeout starts new function call stack, so iOs Safari doesn't allow that .focus(). But, important! This code won't work, if your input is hidden with display: none (or some of it ancestors). You can't set focus to the hidden element. That's why this timeout is here - it waits when angular shows the dropdown. I use select2 theme, so I updated my styles with:

.select2-display-none {
  overflow: hidden;
  height: 0;
  opacity: 0;
}

Also I recommend to disable focusser activation on select close, to prevent iOS keyboard jumping. Here is the code of close function. My code is:

ctrl.close = function() {
    if (!ctrl.open) return;
    if (ctrl.ngModel && ctrl.ngModel.$setTouched) ctrl.ngModel.$setTouched();
    _resetSearchInput();
    ctrl.open = false;

    $scope.$broadcast('uis:close', true);

  };

Conclusion I don't know how to fix that properly in ui-select, but one of the approaches is to replace the timeout in first piece of code and show dropdowns not by angular class, but with immediate style update before focus (remove 'display: none'). About jumping keyboard on close... I don't know why skipFocusser is in the close function, so cannot suggest how to prevent skpFocusser === false for iOS here.

driver-by avatar May 21 '15 11:05 driver-by

+1

hjmodha avatar May 26 '15 09:05 hjmodha

+1

ahuang321 avatar Jul 22 '15 04:07 ahuang321

+1

madmed88 avatar Jul 22 '15 08:07 madmed88

+1

amrsh avatar Sep 03 '15 23:09 amrsh

+1

adolfov avatar Nov 03 '15 00:11 adolfov

+1

AlemaoEc avatar Nov 10 '15 11:11 AlemaoEc