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]: EditorContent refs merged incorrectly #6170

Open
1 task done
ghaikanav opened this issue Mar 11, 2025 · 0 comments
Open
1 task done

[Bug]: EditorContent refs merged incorrectly #6170

ghaikanav opened this issue Mar 11, 2025 · 0 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

@ghaikanav
Copy link

Affected Packages

react

Version(s)

2.9.1

Bug Description

I have 3 tip tap editors on a page for a use case of mine, each of them has a ref attached to it, and an event listener to listen clicks.

 const handleClick = (event: MouseEvent) => {
    const element = event.target as HTMLElement;
    console.log("something clicked");
  };

 useEffect(() => {
    const currentEditorRef = editorRef.current;
    console.log("currentEditorRef", currentEditorRef);

    if (currentEditorRef) {
      currentEditorRef.addEventListener("click", handleClick);
    }

    return () => {
      if (currentEditorRef) {
        currentEditorRef.removeEventListener("click", handleClick);
      }
    };
  }, [editorRef]);

<EditorContent
    ref={editorRef}
    name={name}
    editor={tipTapEditor}
/>

All the logs point to a given editor and only when I click that given editor something gets logged. But if I wrap the <EditorContent /> in a div and attach refs to the divs, all works properly.

<div ref={editorRef}>
  <EditorContent
    name={name}
    editor={tipTapEditor}
  />
</div>

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

Each <EditorContent/> should behave like any other div when a ref is attached to it, no matter how many instances of it are present in the document.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@ghaikanav ghaikanav 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 Mar 11, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Tiptap: Issues Mar 11, 2025
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
Status: Needs Triage
Development

No branches or pull requests

1 participant