svelte
svelte copied to clipboard
Cursor jumps to end in search box in Safari
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
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?
I don't have easy access to Safari to test this, but this should be fixed in 3.44.3 thanks to @skippednote
Unfortunately it doesn't seem to have fixed it, tested with https://svelte.dev/repl/ede78dee46f74e088fcc07241a389363?version=3.44.3.
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?
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?
@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.
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.
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
Confirmed (again). Still broken on Safari 13 (iOS 13.6.1). This is a really annoying bug :(