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

[Bug]: commands.focus() triggers blur #5992

Open
1 task done
elledienne opened this issue Jan 6, 2025 · 2 comments
Open
1 task done

[Bug]: commands.focus() triggers blur #5992

elledienne opened this issue Jan 6, 2025 · 2 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@elledienne
Copy link

elledienne commented Jan 6, 2025

Affected Packages

core

Version(s)

2.11.0

Bug Description

After upgrading to 2.11.0, calling editor.commands.focus() triggers a focus and blur event in short succession

Browser Used

Chrome

Code Example URL

https://codesandbox.io/p/sandbox/friendly-paper-wzyqyg

Expected Behavior

Blur should not fire

Additional Context (Optional)

I'm positive this issue is caused by this PR which changes how focus is triggered - in fact, commenting out that line of code fixes the issue for me

Dependency Updates

  • Yes, I've updated all my dependencies.
@elledienne elledienne added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Jan 6, 2025
@bdbch
Copy link
Member

bdbch commented Jan 8, 2025

I wasn't able to reproduce it myself, no Blurring console.log was printed when I reload the page. Could you describe a bit more what exactly this is breaking or when this is caused?

I tried adding a button that will run the blur command too and same here - I only received the Blurring console log once as expected since we blur the editor when you click the button but no additional blur event was sent.

@elledienne
Copy link
Author

I made a video for you. It shows that Blurring is being fired when the useEffect triggers the focus command
https://github.com/user-attachments/assets/bac606fc-ad3a-4956-aa3a-8d26900aa500

In our app, the issue is exactly the same as in this demo. When we programmatically focus on the editor, the onBlur fires which is quite problematic for us as onBlur is actually meant to close the editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

2 participants