angular-xeditable icon indicating copy to clipboard operation
angular-xeditable copied to clipboard

Control does not receive focus when shown in Safari for iOS

Open mbaranov opened this issue 11 years ago • 10 comments

In order to reproduce the issue, please navigate to http://vitalets.github.io/angular-xeditable/#text-simple and click on "awesome user" label in the demo section.

When using non-iOS device the text box shown after the click is automatically focused and a user is able to start editing the text immediately.

In Mobile Safari (we tested it on iOS 6), the text box does not receive focus, and user has to tap on the just appeared editor control in order for the virtual keyboard to show up, so that the text could be edited.

Our initial research of the problem pointed to the restriction in the Mobile Safari, which prohibits focusing an element in any event handler, except the one that is generated directly by the user. (Please refer to the accepted answer here http://stackoverflow.com/questions/6287478/mobile-safari-autofocus-text-field for more details).

That means that the .focus() call will not work in setTimeout() callback, which seems to be the way it's currently called in the control (https://github.com/vitalets/angular-xeditable/blob/master/src/js/editable-element/controller.js#L373). It appears, that setTimeout() usage is necessary for the angular bindings to be proprely handled, though.

Is there any way to fix the controls to allow an editor be autofocused when it's shown when running in Mobile Safari for iOS?

Thanks in advance.

mbaranov avatar Jan 20 '14 13:01 mbaranov

hi, thanks for reporting. I'll try to investigate into this issue..

vitalets avatar Jan 23 '14 08:01 vitalets

Yes, this is a huge problem for me right now.

kopch avatar Apr 24 '14 09:04 kopch

+1 Any updates for this one? @vitalets can you explain the reason for the setTimeout(...,0) to me. I've currently commented this line and experienced no issues so far (+ iOS focus working)

bezoerb avatar Sep 14 '14 20:09 bezoerb

Ok, now i got the reason for the setTimeout ;) Error: error:inprog Action Already In Progress

bezoerb avatar Sep 19 '14 04:09 bezoerb

Any update on this problem?

laurensnl avatar Apr 16 '15 20:04 laurensnl

It's a problem for me too.

taglia avatar May 29 '15 07:05 taglia

+1 Any updates?

atremel avatar Sep 14 '15 10:09 atremel

+1

mpfund avatar Dec 02 '15 16:12 mpfund

This is still an issue. I played around with the code and wasn't able to find a solution.

ckosloski avatar Jan 27 '17 16:01 ckosloski

+1. Still an Issue, not yet resolved.

abhilashcode avatar Dec 03 '18 14:12 abhilashcode