tiptap: `autofocus` doesn't work with Hocuspocus
What’s the bug you are facing?
While setting autofocus to start or 0 (which is, from my understanding, supposed to do the same thing?) with Hocuspocus as a back-end, it doesn’t work as intended (focus being put at the end of the document).
I guess the issue is caused by Hocuspocus content being synchronized asynchronously, so the following is probably happening:
- Editor is instantiated, empty
- Focus is put at the start of the document
- Content is loaded by the Collaboration extension and cursor/focus being “moved” to the end of the document (kind of “pushed” by the content)
It’s just a guess, maybe it’s something totally different.
Which browser was this experienced in? Are any special extensions installed?
Tested on Firefox 101.0 and Edge 102.0.1245.30 (both latest versions).
Extensions installed:
DocumentParagraphTextCollaboration(with Hocuspocus)
How can we reproduce the bug on our side?
Clone https://github.com/Deckluhm/tiptap-hocuspocus-autofocus and follow README instructions.
Can you provide a CodeSandbox?
See provided repository above.
What did you expect to happen?
autofocus: 'start' should work with Hocuspocus/Tiptap Collaboration extension.
Anything to add? (optional)
As a temporary workaround I tried to disable autofocus, listen to Hocuspocus provider synced event and manually call editor.commands.focus('start') but it’s not working (probably because synced doesn’t mean content has been rendered by Tiptap).
Did you update your dependencies?
- Yes, I’ve updated my dependencies to use the latest version of all packages.
Are you sponsoring us?
- Yes, I’m a sponsor. 💖
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (11 by maintainers)
for me the autofocus doesnt work at all with the collaboration extension enabled. Without it, it works well. I am also using hocuspocus.
Would it be possible for
remove yUndoPlugin() from 'addProseMirrorPlugins' method and register yUndoPlugin() manually in onCreate hook,to be a permanent fix for the extension?Just commenting because it is still an issue.