ueberdosis / tiptap

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

Cannot switch focus from editor to an outside element in certain scenarios #1299

Closed zcuric closed 3 years ago

zcuric commented 3 years ago

Description When adding link or image through custom form menu, cannot switch focus to the input field from editor. Focus is stuck on editor, which wasn't the case in tiptap@1

Steps to reproduce the bug

  1. Create an form that will activate on button click with input field
  2. Try to change focust with this.$refs.input.focus

Expected behavior Focus should be switched to input

Screenshot, video, or GIF image

Environment?

zcuric commented 3 years ago

After checking this out of my working environment in an isolated sandbox, this seems to be an issue with my environment.

oliviermills commented 3 years ago

I am having the same issue. @zcuric What was the issue with your environment that caused it?

oliviermills commented 3 years ago

I am having the same issue. @zcuric What was the issue with your environment that caused it?

In my case I was overusing the .focus() in my menu bar items.

ntcho commented 3 years ago

In my case I was overusing the .focus() in my menu bar items.

I had the same problem. I mistakenly added a function invocation instead of a function body to the onClick props.

It was like:

<Button
  onClick={editor.chain().focus().toggleBulletList().run()}
  ...
/>

But it should be like this:

<Button
  onClick={() => editor.chain().focus().toggleBulletList().run()}
  ...
/>

Ctrl + Shift + F on VS Code to search all focus() usage and check whether you are calling focus() on every re-render.