You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed the onSelect event sometimes runs with the old selection value, sometimes with the new selection.
If you select text multiple times, in combinations of range select and click especially, every once in a while it will report the old value.
This makes certain other kinds of bugs hard to catch for developers, because the behavior is erratic.
The onSelect handler is a synthetic React polyfill that isn't really triggered when the selection changes (it's trigger on click, on keydown, etc.). Unfortunately the React events started out as proper spec-compliant polyfills, but that was years ago and they haven't kept pace, so these days there are many gaps that aren't properly covered and it doesn't seem like they're going to fix the synthetic events at all. Here's an issue specifically tracking selectionchange: facebook/react#5785
If you're looking to do things when the editor's selection changes you should likely use onChange instead. I'd be open to adding an onDOMSelectionChange if someone wants to PR to get the real DOM event which would actually be accurate.
Do you want to request a feature or report a bug?
Report a bug.
What's the current behavior?
I have noticed the onSelect event sometimes runs with the old selection value, sometimes with the new selection.
If you select text multiple times, in combinations of range select and click especially, every once in a while it will report the old value.
This makes certain other kinds of bugs hard to catch for developers, because the behavior is erratic.
https://codesandbox.io/s/slate-reproductions-8n7q5
https://recordit.co/j053446P1S
Slate: 0.56.0
Browser: Chrome
OS: Windows
What's the expected behavior?
onSelect should fire consistently, with the value of the new selection made.
The text was updated successfully, but these errors were encountered: