primer / react

An implementation of GitHub's Primer Design System using React
https://primer.style/guides/react
MIT License
3.16k stars 536 forks source link

`MarkdownEditor` suggestions break when querying by 3 or more characters #2423

Closed iansan5653 closed 2 years ago

iansan5653 commented 2 years ago

We noticed an odd bug in Projects today (https://github.com/github/memex/issues/12620) -- when the user types more than 2 characters to filter the suggestions list, the suggested values become completely incorrect. For 2 or fewer characters, the suggestions make sense, but something seems to break after that. I was able to reproduce this by adding a few more suggestions to the MarkdownEditor story.

In this list, "GitHub" should be first and "mnl" shouldn't appear at all:

Screenshot of the MarkdownEditor suggestions. The user has typed '@git' and the first suggestion is the user 'mnl'.
iansan5653 commented 2 years ago

I've found out that this is because fzy.js (the fuzzy filtering library we are using) returns Infinity if the length of the match item is less than the length of the query (and the shortest username a user on GitHub can have is 3 characters).