svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Cursor jumps to end in search box in Safari

Open layday opened this issue 4 years ago • 9 comments
trafficstars

Describe the bug

The cursor in a search box (input[type="search"]) with a two-way value binding jumps to the end when typing in Safari. I don't know my way around the Svelte code base, but looking at previous cursor issues, I think 'search' would have to be added to the if condition here.

Reproduction

<script>
  let foo: string = '';
</script>

<input type="search" bind:value={foo}>

https://svelte.dev/repl/ede78dee46f74e088fcc07241a389363?version=3.44.1

Logs

No response

System Info

n/a

Severity

annoyance

layday avatar Nov 10 '21 08:11 layday

Yup, looking at #4179 where this code was originally added, this sounds like a reasonable suggestion. Are there other text-like input types we should also be handling? Or, would it be better to just exclude all of the types that aren't text-like, which might make this a little more future-proof?

Conduitry avatar Nov 10 '21 11:11 Conduitry

I don't have easy access to Safari to test this, but this should be fixed in 3.44.3 thanks to @skippednote

Conduitry avatar Dec 13 '21 19:12 Conduitry

Unfortunately it doesn't seem to have fixed it, tested with https://svelte.dev/repl/ede78dee46f74e088fcc07241a389363?version=3.44.3.

layday avatar Dec 13 '21 20:12 layday

This seems to be working correctly on Release 136 (Safari 15.4, WebKit 17613.1.9.2) (Technical Preview) on my end. Issue in Safari?

kevmodrome avatar Dec 13 '21 20:12 kevmodrome

The additional input.value !== /*foo*/ ctx[0] condition that I would have expected to see in 3.44.3 isn't present, which means that the change to handle type=search (and others) the same way as type=text isn't working as intended, which I'd like to dig into, regardless of which versions of Safari this bug affected.

@kevmodrome Did you see the behaior in 3.44.1, the original version this issue was opened against?

Conduitry avatar Dec 13 '21 20:12 Conduitry

@kevmodrome Did you see the behaior in 3.44.1, the original version this issue was opened against?

I've tried in the current version of Safari as well as the TP. In the current version both Svelte 3.44.1 and 3.44.3 are broken. In the TP version they both work correctly.

kevmodrome avatar Dec 13 '21 20:12 kevmodrome

Ah! It looks like #6941 just handled the code for one-way binding. And that's all that was originally covered in #3449 and in #4179. So, the two-way binding mentioned here would be a separate issue, which I'd completely missed while looking at this before.

I'll update the changelog for 3.44.3 so it correctly reflects what that version fixed, but I'm still unclear what specifically is happening in this issue or what can be done about it.

Conduitry avatar Dec 13 '21 20:12 Conduitry

I can confirm, input type "search" and "tel" not working properly on iOS 15.2

Link to repl: https://svelte.dev/repl/f2f27573a86c4940b0749005f3d7233b?version=3.44.3

https://user-images.githubusercontent.com/49361135/159015454-850f5626-aa93-49da-a092-05ef805dd3a6.mp4

pointmax avatar Mar 18 '22 13:03 pointmax

Confirmed (again). Still broken on Safari 13 (iOS 13.6.1). This is a really annoying bug :(

Azarattum avatar Jul 25 '22 12:07 Azarattum