-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: unexpected event triggered when using ReactEditor.focus #5677
fix: unexpected event triggered when using ReactEditor.focus #5677
Conversation
🦋 Changeset detectedLatest commit: 918b30f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @WindRunnerMax . I'm going to approve and land this, but it's possible I'm forgetting a reason why that onChange call was in there. If there was a valid reason we may need to revert, we'll see!
Description
When opening the document for the first time, using
ReactEditor.focus
to focus on the document unexpectedly triggers theonValueChange
event, and there will also be an additionalonChange
event triggered.Issue
Fixes: #5672
Example
The debug code is shown below, and the autoFocus property of Editable is turned off.
slate/site/examples/richtext.tsx
Lines 30 to 50 in 631a911
The effect when calling ReactEditor.focus is shown in the image, where you can see the unexpected event triggers.
Context
Actually, calling
onChange
inReactEditor.focus
isn't necessary. If needed,Transforms.select
will handle triggering the event.Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)