Skip to content
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

ReactEditor.focus triggers onValueChange unexpectedly #5672

Closed
gwy15 opened this issue Jul 4, 2024 · 1 comment · Fixed by #5677
Closed

ReactEditor.focus triggers onValueChange unexpectedly #5672

gwy15 opened this issue Jul 4, 2024 · 1 comment · Fixed by #5677
Labels

Comments

@gwy15
Copy link

gwy15 commented Jul 4, 2024

Description
Playground: https://codesandbox.io/s/api-focus-triggers-onvaluechange-dlsfxx?file=/src/App.tsx:962-975

for a simple <Slate />, mannually focus / blur using cursor does not trigger its onValueChange event.
However if using ReactEditor.focus(editor);, onValueChange event is triggered (and only for the first call, weirdly).

Recording
20240704170143_rec_

Sandbox
https://codesandbox.io/s/api-focus-triggers-onvaluechange-dlsfxx?file=/src/App.tsx:962-975

Steps
To reproduce the behavior:

  1. Go to Sandbox
  2. Click on the button
  3. a onValueChange event is triggered.

Expectation
A consistent behavior (i.e., either both mannually focus and api focus triggers the onValueChange event, or neither does, which I guess is more reasonable.

Environment

  • Slate Version: 0.103
  • Operating System: macOS
  • Browser: Chrome and Safari
  • TypeScript Version: 3.7.5
@WindrunnerMax
Copy link
Contributor

Before this issue is resolved, I think you can use editor.apply to dispatch events, something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants