fix issue #5814. onValueChange not triggered when selecting text from right to left
onValueChange not triggered when selecting text from right to left
✅ Closes: #5814
Description when selecting text from right to left, it will trigger set_selection, remove_text, insert_text at the same time, cause onValueChange not trigger.
Issue Fixes: (link to issue)
Example
🦋 Changeset detected
Latest commit: 42bb61b2dc0a8b5645fc05ab38d2a14f615eef2d
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| slate | Patch |
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
@virgil1996 this looks reasonable. Could you please add a changeset as a patch and I'll land this.
done.
With how the flushing flag is separated, this will trigger onChange twice in one frame, so any generic behavior will trigger twice. (the second will also be called while editor.operations is empty)
seems like strange behavior to have in core slate--since onValueChange and onSelectionChange are slate-react specific concepts.
I think it would make more sense if the slate-react onChange handler could see all the operations in a frame and decide to run one or both of the sub-events with one call.
Agree with @nabbydude. Migrating from operation to batch: Operation[] (or operations) should enable the solution.