Below given is the code I'm trying to implement.
Here, if I type my desired name, the source()
function calls the renderList()
and runs properly because matches
is not empty.
The problem arises that if I mistype (or, write a name that does not exist, i.e., searchTerm
does not match any name), the matches
list becomes empty causing the renderList()
to not able to show any list and thus closing the mention dropdown list. Now, if I delete the mistyped part, the mention dropdown should've reappeared, but it is reappearing only when I delete the whole searchTerm
because it finds the mentionChar
and then triggers the onOpen()
method.
if (searchTerm.length === 0) {
renderList(values, searchTerm);
} else {
const matches: any[] = [];
values.forEach((entry: { searchValue: any; value: string }) => {
if (
entry.value.toLowerCase().indexOf(searchTerm.toLowerCase()) !== -1
) {
matches.push(entry);
}
});
renderList(matches, searchTerm);
}
Is there any way that to not close the mention dropdown in case any matches are not found. Given I have the requirement to not show any suggestions if typed wrong or no matches found.
I tried to find any solution on Github's Quill Mention repo, but couldn't find any.