-
-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Description
Reproduce example link: https://codesandbox.io/p/sandbox/react-codemirror-example-codemirror-6-forked-sj8ynr
Reproduce:
- open the example link
- select unmodified content or select all content (important: after update selection should not to be collapsed)
- click to the update content button
expected result: Editor selection restored
alternative expected result: Editor selection and browser selection not showed
actual result:
- Editor selection now showed
- Browser selection exist (green color of the text for demonstration)
demonstration:
editor.webm
workaround:
clear browser selection state before update editor state:
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
Metadata
Metadata
Assignees
Labels
No labels