Skip to content

Commit

Permalink
Ensure the selection is synced
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Jun 28, 2024
1 parent 89186e3 commit 73ed8e9
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ export const useFieldV6TextField: UseFieldTextField<false> = (params) => {
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
}
}
setTimeout(() => {
// handle case when the selection is not updated correctly
// could happen on Android
if (
inputRef.current &&
inputRef.current === getActiveElement(document) &&
(inputRef.current.selectionStart !== selectionStart ||
inputRef.current.selectionEnd !== selectionEnd)
) {
interactions.syncSelectionToDOM();
}
});
}

// Even reading this variable seems to do the trick, but also setting it just to make use of it
Expand Down

0 comments on commit 73ed8e9

Please sign in to comment.