draft-js-plugins: Forcing focus breaks plugins
I’ve noticed that when i call focus() on the Editor, the emoji and mention plugins do not work – that is, they do not respond to : or @ and suggestions do not populate. I’m guessing focus() is somehow messing with the selectionState…any ideas on this?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 20
- Comments: 21
Commits related to this issue
- focus break mentions plugin https://github.com/draft-js-plugins/draft-js-plugins/issues/800 put it into setTimeout WAT — committed to openland/openland-apps by sergey-lapin 6 years ago
- Revert "focus break mentions plugin https://github.com/draft-js-plugins/draft-js-plugins/issues/800 put it into setTimeout WAT" This reverts commit 7f3f943cb1d92db720e811f46e04b19b5a854000. — committed to openland/openland-apps by sergey-lapin 6 years ago
- Fix Text block focus -> lose plugins See https://github.com/draft-js-plugins/draft-js-plugins/issues/800 — committed to plone/volto by avoinea 4 years ago
I was able to find a temporary solution to this problem by using
setTimeouton the call tofocus:setTimeout(this.editor.focus, 50)Strangely enough, this seems to solve the problem even if you set the timeout value to 0.
My original guess on why this works was that there is still something in the mention suggestions that is still in the process of mounting or rendering, but the parent component’s
componentDidMountshould’t be called until after all this is complete…so really not sure.I just spent about 2 hours to figure out why my
mentionandlinkifyplugin weren’t working. That was so frustrating.We should give more attention to this issue.
This is a major issue, and has barely been acknowledged in 2 years :\ I guess this repo is no longer maintained?
+1, can we please at least add documentation for this?
The underlying issue is something like this (from memory):
tried switching from doing this
to calling
focus()on the DOM element directly like soboth focus the editor correctly, but the problems with mentions persisted