Tiptap: Editor method `focus()` doesn't work

Created on 16 Jul 2019  路  7Comments  路  Source: ueberdosis/tiptap

Describe the bug
Editor method focus() doesn't work.
image

This does not work on tiptap 1.23.2 and used to work. This is likely a regression.

Steps to Reproduce / Codesandbox Example

  1. init the editor via const editor = new Editor()
  2. call to editor.focus()
  3. does not focus.

https://codesandbox.io/s/editor-focus-does-not-work-g48i0?fontsize=14

Expected behavior
Focus the editor :P

Screenshots
image

Environment

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]
  • Mobile / Desktop: [eg. Desktop]

Additional context
Add any other context about the problem here.

bug

Most helpful comment

I found a solution - editor.view.dom.focus()

All 7 comments

The same here. Focus doesn't work properly.

I found a solution - editor.view.dom.focus()

You're the king!

However, there is one more think i should add. That one works better when you use it for click events:

this.$nextTick( () => {
   this.editor.view.dom.focus()
})

@screets please stop these automatic emails :)

Thanks @vitaliy-grusha, editor.view.dom.focus() still works, but is there a way to set the cursor to the very end?

Try editor.focus('end')! Hope that helps.

Thanks for the quick reply @hanspagel! That worked perfectly 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

connecteev picture connecteev  路  3Comments

Auxxxxlx picture Auxxxxlx  路  3Comments

bernhardh picture bernhardh  路  3Comments

santicros picture santicros  路  3Comments

dolbex picture dolbex  路  3Comments