question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mentions Not Triggering with Second Instance of Plugin

See original GitHub issue

Use-case/Problem

I am using the CustomMentionsEditor defined here https://www.draft-js-plugins.com/plugin/mention. My site has an instance of the CustomMentionsEditor which loads when the site loads, allowing users to post new comments and mention other users. However, the same CustomMentionsEditor is loaded again later when someone presses “Reply” on somebody else’s comment. This second CustomMentionsEditor does not trigger the MentionsSuggestions. I am also using the StaticToolbar plugin, and this works fine in both editors. I’ve followed suggestions about updating the EditorState using

EditorState.push(this.state.editorState, ContentState.createFromText(''))

however, this doesn’t fix the issue. I’ve also looked at the FAQ which says you must define separate instances of the plugin if you want to reuse them in the same component, however this is not my use case as I am only using one instance of the plugin in the component, it’s just that the component itself has two instances on the site.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
Rykunocommented, Mar 7, 2020

I found a solution for this issue. Basically for each editor rendered you must make a new instance of the plugins.

 const [{ plugins, InlineToolbar, CustomCounter }] = useState(() => {
    const inlineToolbarPlugin = createInlineToolbarPlugin();
    const counterPlugin = createCounterPlugin();

    const { CustomCounter } = counterPlugin;
    const { InlineToolbar } = inlineToolbarPlugin;

    const plugins = [inlineToolbarPlugin, counterPlugin];
    return {
      plugins,
      InlineToolbar,
      CustomCounter
    };
  });

Refer to this issue https://github.com/draft-js-plugins/draft-js-plugins/issues/1244

0reactions
stale[bot]commented, Sep 10, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple instances of jQuery plugin on same page is not working
Your plugin is written to only connect to a single jQuery element at a time. You can improve that like this: // plugin...
Read more >
How to use the draft-js-mention-plugin function in draft ... - Snyk
In this case, only the mentionPlugin // is passed in, although it is possible to pass in multiple plugins. const MyEditor = ({...
Read more >
prevent plugin to run multiple instances on the same time
I have a plugin which is registered with several steps on multiple entities. ... this is no problem when I edit records over...
Read more >
Jenkins Artifactory Plug-in - JFrog
The new plugin also does not support UI based Jenkins jobs, such as Free-Style ... This integration allows triggering a Jenkins job from...
Read more >
Notification – Custom Notifications and Alerts for WordPress
How easy extending the Notification plugin is? Let's see: Adding another Merge Tag to existing trigger – 1 line of code; Creating custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found