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

fix(react): fix rebinding events not overwriting editor.on #3935

Merged
merged 2 commits into from
Apr 3, 2023

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Apr 3, 2023

Please describe your changes

This PR fixes the issue described in #3932 by unbinding specific event handlers instead of all event handlers in a hook inside useEditor.

How did you accomplish your changes

  1. Save the event handlers into refs to compare them afterwards for unbinding
  2. Whenever a changed event handler is registered, unbind the old one, register the new one
  3. Save the new one was the old one for next check

How have you tested your changes

I created a local demo to test this behavior. It didn't create to many callbacks & correctly unregistered old ones. Also events registered via Editor.on were working correctly.

How can we verify your changes

Create a local React demo and register a callback via editor.on.

Remarks

Nothing to remark

Checklist

  • The changes are not breaking the editor
  • Added tests where possible
  • Followed the guidelines
  • Fixed linting issues

Related issues

@bdbch bdbch requested a review from svenadlung April 3, 2023 14:04
@bdbch bdbch self-assigned this Apr 3, 2023
@netlify
Copy link

netlify bot commented Apr 3, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 1e175bc
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/642ae35834ba2c0007c20382
😎 Deploy Preview https://deploy-preview-3935--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bdbch bdbch merged commit 64ab357 into main Apr 3, 2023
@bdbch bdbch deleted the hotfix/fix-event-binding-react branch April 3, 2023 15:30
aliasliao pushed a commit to aliasliao/tiptap that referenced this pull request May 24, 2023
…s#3935)

* fix(react): fix rebinding events not overwriting editor.on

* fix(react): move ref assignment inside if
andrewlu0 pushed a commit to trybaseplate/tiptap that referenced this pull request Oct 20, 2023
…s#3935)

* fix(react): fix rebinding events not overwriting editor.on

* fix(react): move ref assignment inside if
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.

2 participants