Draft-js-plugins: draft-js-mention-plugins: mentionSuggestions is handling up/down arrow keys even when it's inactive

Created on 30 Jan 2018  路  3Comments  路  Source: draft-js-plugins/draft-js-plugins

Use-case/Problem

This was initially reported in https://github.com/draft-js-plugins/draft-js-plugins/issues/856. I'm running the current master of this repo and still running into this issue. I have looked at the source and I will submit a PR that I think should fix this. I can't reproduce this in the example because the mentions don't change in that example, therefore the mentionSuggestions.componentWillReceiveProps is never called, but when it is, it will either open the dropdown or close it based on whether the suggestions have changed or not, which doesn't make sense to me (if the dropdown is open when props change, keep it open, if closed, then keep it closed).

bug mentions-plugin stale

Most helpful comment

I ran into this because I was filtering the suggestions upon render, which makes the equality check on suggestions always fail here: https://github.com/draft-js-plugins/draft-js-plugins/blob/master/draft-js-mention-plugin/src/MentionSuggestions/index.js#L36

(since it is two different references to arrays that happen to have the same items)

Switched over to filtering the suggestions in onSearchChange, and storing the result in state and got my up and down arrows back.

All 3 comments

I ran into this because I was filtering the suggestions upon render, which makes the equality check on suggestions always fail here: https://github.com/draft-js-plugins/draft-js-plugins/blob/master/draft-js-mention-plugin/src/MentionSuggestions/index.js#L36

(since it is two different references to arrays that happen to have the same items)

Switched over to filtering the suggestions in onSearchChange, and storing the result in state and got my up and down arrows back.

I ran into this because I was filtering the suggestions upon render, which makes the equality check on suggestions always fail here: https://github.com/draft-js-plugins/draft-js-plugins/blob/master/draft-js-mention-plugin/src/MentionSuggestions/index.js#L36

(since it is two different references to arrays that happen to have the same items)

Switched over to filtering the suggestions in onSearchChange, and storing the result in state and got my up and down arrows back.

I had a similar issue and and based on your workaround i wrapped my suggestions into useMemo hook. The problem is gone 馃敟

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.

Was this page helpful?
0 / 5 - 0 ratings