Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

virgil1996
Copy link

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

Copy link

changeset-bot bot commented May 8, 2025

🦋 Changeset detected

Latest commit: 42bb61b

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 virgil1996 changed the title fix issue #5814. onValueChange not triggered when selecting text from right to left then fix issue #5814. onValueChange not triggered when selecting text from right to left May 8, 2025
Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

onValueChange not triggered when selecting text from right to left

✅ Closes: ianstormtaylor#5814
@virgil1996
Copy link
Author

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

done.

@nabbydude
Copy link
Contributor

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.

@virgil1996 virgil1996 requested a review from dylans July 10, 2025 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onValueChange not triggered when selecting text from right to left then paste
3 participants