fix: cursor jumps in input two way binding#16649
Conversation
Old Fix: Restore input binding selection position (sveltejs#14649) Current Fix: Remove unnecessary cursor manipulation as the presence of runes no longer requires special handling.
🦋 Changeset detectedLatest commit: 0357b5f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
This breaks a case like this (compare to the latest version) <input bind:value={() => name, v => name = v.toUpperCase()} />To elaborate: the input and the variable get desynced. |
This reverts commit 9109494.
Introduced Promise.resolve to ensure that the 'set' operation completes before the 'get' operation Minimizing update delays.
|
Hey @7nik Thanks for highlighting that. |
|
So, now the input and the variable get desynced because of the "Never rewrite the contents of a focused input" case. But don't we still want to write if it's the latest batch? |
…r a tick so that changes have been flushed through each blocks
|
Ah whoops, you're right. So yes, we do need to handle it in the event handler and not in the subsequent effect, and the reason we can't do it immediately is because of a quirk of how Updated the PR to make that explicit. Thanks! |
|
gah the test failure is bizarre. Passes fine when the test runs individually but not when the entire suite runs? |
|
Hi @Rich-Harris , quick question out of curiosity. I noticed the latest commit you have changed is the callback method to be async & waiting for requestAnimationFrame(). I am wondering how this approach differs from my simpler solution which waits for SET synchronous callback to end first and the call GET. What potential drawbacks my solution might have. ? Could you help me understand the benefits and perhaps suggest an even better way to handle this? |
|
|
|
great. thanks for the info @7nik |
Old Fix: Restore input binding selection position (#14649) .
Current Fix: Remove unnecessary cursor manipulation written for (#14649) as the presence of runes no longer requires special handling.
This fix closes #16634
Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.packages/svelte/src, add a changeset (npx changeset).Tests and linting
pnpm testand lint the project withpnpm lint