ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
27.68k stars 2.3k forks source link

Global styles get removed when destroying editor even if there are other editors alive #2143

Closed pie6k closed 3 years ago

pie6k commented 3 years ago

What’s the bug you are facing?

Global styles (https://github.com/ueberdosis/tiptap/blob/main/packages/core/src/style.ts) are added to <head> when editor is created and removed when editor is destroyed.

This works fine if using only one editor on the page.

However, if using multiple editors, if one of them is removed, but others are still alive - those styles are still removed causing slight layout changes.

Thus I think there should be some sort of global counter that counts remaining alive instances and removes the styles only if there are no alive editors left.

How can we reproduce the bug on our side?

Create 2 react editors.

Perform react update that removes one of them.

Expected result: global styles are still present Actual result <style data-tiptap-style> tag is removed from head.

Can you provide a CodeSandbox?

No response

What did you expect to happen?

Have global styles alive as long as any editor instance is running

Anything to add? (optional)

No response

Did you update your dependencies?

Are you sponsoring us?

philippkuehn commented 3 years ago

Ah yes, I think this issue is related to #2120