slate icon indicating copy to clipboard operation
slate copied to clipboard

fix issue #5814. onValueChange not triggered when selecting text from right to left

Open virgil1996 opened this issue 11 months ago • 2 comments

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 image

virgil1996 avatar May 08 '25 07:05 virgil1996

🦋 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

changeset-bot[bot] avatar May 08 '25 07:05 changeset-bot[bot]

@virgil1996 this looks reasonable. Could you please add a changeset as a patch and I'll land this.

done.

virgil1996 avatar May 15 '25 10:05 virgil1996

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.

nabbydude avatar Jun 19 '25 07:06 nabbydude

Agree with @nabbydude. Migrating from operation to batch: Operation[] (or operations) should enable the solution.

zbeyens avatar Aug 07 '25 12:08 zbeyens