joelewis / prosemirror-mentions

ProseMirror plugin to enable @mentions and #hashtags
MIT License
114 stars 32 forks source link

Calling mention suggestions callback with empty list causes crash (patch included) #39

Open macavity23 opened 2 years ago

macavity23 commented 2 years ago

In my Mentions plugin (created using getMentionsPlugin), when getting suggestions, my code calls the done callback with an empty list to indicate no matching suggestions, but this causes a crash in mentionPlugin.js:addClassAtIndex ("prevItem is undefined" due to there being no matching element).

The patch below adds a simple check to addClassAtIndex to fix this issue, and also in related function removeClassAtIndex.

prosemirror.patch.txt

stof commented 2 years ago

you should probably open a pull request with your patch