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: Usage of editor.chain().focus() removes focus from tippy popover #412

Closed
tautastic opened this issue Jun 21, 2024 · 2 comments · Fixed by #413 · May be fixed by patooworld/patooworld-site-kit#32 or patooworld/animated-waffle#13

Comments

@tautastic
Copy link
Contributor

tautastic commented Jun 21, 2024

Provide environment information

System:
OS: macOS 14.5
CPU: (14) arm64 Apple M3 Max
Memory: 68.82 GB / 96.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.7.1 - /opt/homebrew/bin/node
npm: 10.5.0 - /opt/homebrew/bin/npm
pnpm: 9.3.0 - /usr/local/bin/pnpm
Watchman: 2024.03.25.00 - /opt/homebrew/bin/watchman

Describe the bug

If we take a look at the color-selector.tsx file, we can see that the text color selection changes the text color like this:

editor.chain().focus().setColor(color || "").run();

while the highlighting color is changed like this:

editor.commands.setHighlight({ color });

The first one causes the tippy popover to lose focus, then appear at the top left corner of the screen, and then regain focus and return to its correct position.

The second one does not do this.

Link to reproduction

https://novel.sh/

To reproduce

  1. Navigate to the example page.
  2. Select any text inside the editor.
  3. Click on the color selector that appears in the popover.
  4. Choose any color from the color selector.
  5. Attempt to select a different color using the color selector.
  6. Observe the described bug occurring when a different color is selected.

Additional information

No response

@mathiasrscom
Copy link

@tautastic I saw this got fixed and updated to 0.5. No I get these issues:

TypeError: editor.commands.unsetColor is not a function
TypeError: editor.chain(...).unsetHighlight is not a function

And a couple of others. What changes do we need to make?

@tautastic
Copy link
Contributor Author

@tautastic I saw this got fixed and updated to 0.5. No I get these issues:

TypeError: editor.commands.unsetColor is not a function

TypeError: editor.chain(...).unsetHighlight is not a function

And a couple of others. What changes do we need to make?

Hm I don't know but taking a look at https:/ueberdosis/tiptap/blob/535dcccb40ca2f17d5db48d5f7a26220a636aafa/packages/extension-color/src/color.ts it seems like editor.commands.unsetColor() should work.

I'll try to figure it out when I have some spare time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment