Reproduce example link: https://codesandbox.io/p/sandbox/react-codemirror-example-codemirror-6-forked-sj8ynr Reproduce: 1. open the example link 2. select unmodified content or select all content (important: after update selection should not to be collapsed) 3. click to the update content button expected result: Editor selection restored alternative expected result: Editor selection and browser selection not showed actual result: 1. Editor selection now showed 2. Browser selection exist (green color of the text for demonstration) demonstration: https://github.com/user-attachments/assets/849dd600-6da5-4e76-9ccd-93fae7ed90f2 workaround: clear browser selection state before update editor state: ```typescript const selection = window.getSelection(); const range = selection?.getRangeAt(0); range?.collapse(true); ``` use collapse https://developer.mozilla.org/en-US/docs/Web/API/Selection/collapse as more safe way either empty https://developer.mozilla.org/en-US/docs/Web/API/Selection/empty
Reproduce example link: https://codesandbox.io/p/sandbox/react-codemirror-example-codemirror-6-forked-sj8ynr
Reproduce:
expected result: Editor selection restored
alternative expected result: Editor selection and browser selection not showed
actual result:
demonstration:
editor.webm
workaround:
clear browser selection state before update editor state:
use collapse https://developer.mozilla.org/en-US/docs/Web/API/Selection/collapse as more safe way either empty https://developer.mozilla.org/en-US/docs/Web/API/Selection/empty