ftlabs / fastclick

Polyfill to remove click delays on browsers with touch UIs
MIT License
18.66k stars 3.23k forks source link

Caret position in input[type=text] and textarea not movable (iOS #414

Closed lexaux closed 9 years ago

lexaux commented 9 years ago

Hi All!

I have noticed a what I think somehow strange behavior. Before diving deeper with workarounds/fix searhc I wanted to shout out if this is somehting normal.

What I observe is that for all fastclick-enabled input[type=text] and textarea, in iOS 8.4 (Safari v8.0 600.1.4) caret (text cursor) is positioned at the end of the text entered regardless of how I try to re-focus it to the middle of the text with taps, for example to fix wording.

  1. Steps to reproduce:
    1. In iOS, Safari, open up http://ftlabs.github.io/fastclick/examples/input.html
    2. Tap on 'Tap me' input (there's actually only one input)
    3. Enter some text
    4. Focus somewhere else (tap outside).
    5. Tap again on the middle of the text in input field
  2. Actual behavior:
    1. Caret stays at the end of the text even after subsequent taps
  3. I would expect that:
    1. That field is focused, and caret is put where the tap happened (that's what happens in a non-enhanced field)
    2. Any subsequent taps reposition caret accordingly.

Probably that is something natural, but I was unable to find a proper workaround for that (probably, just disabling fastclicks for inputs then?)

Cheers, and thanks for the excellent lib! Alex.

lexaux commented 9 years ago

All,

Sorry for the buzz, I've found out the solution. Basically this issue is similar to #338, the only difference to me was that cursor was inside the field, not pushed out - but still not useable.

For me, https://github.com/dieulot/jvforum/commit/7821c20c6cae359d974c9d2e6114b9bb587a77dd?diff=unified this workaround helped.

zorzysty commented 8 years ago

@lexaux Could you please provide working link to the solution that worked for you?

lexaux commented 8 years ago

hi @zorzysty, basically this issue was a sort of combination of original fastclicks and the one shipped with Framework7, the framework we've been using.

What happened is that f7 has its own patched version of fastclicks. We first tried fixing the focus issue by disabling the bundled one, and adding vanilla one with a little fix first. This is the fixed version https://github.com/lexaux/fastclick - there was something minor, and not really that good a fix.

Down the line, we upgraded the framework and the problem disappeared with the freshest version, so we got rid of vanilla extra dependency.

Sorry for that being not too helpful.