autocomplete popup doesn't close

not sure if this is relevant anymore but i followed this suggestion and wrapped my completion source to customize the list. myCompletions takes in a list and further customizes it). but now that im including it with the following

EditorState.languageData.of(() => [{ autocomplete: myCompletions(customList) }])

the autocomplete dropdown doesn’t close after making a selection or when i delete characters (and eventually i dont have any characters before the cursor). what could i be doing wrong?

export function myCompletions(list: string[], isCustomize: boolean) {
  return (ctx: CompletionContext) => {
    const before = ctx.matchBefore(/[\w$]+/);

    if (!ctx.explicit && !before) {
      return null;
    const currentWord = before.text;
    const regex = new RegExp(`^${currentWord}`, 'i'); // regex for matches in custom list
    const resultList = !currentWord
      ? list
      : list.filter((item: string) => item.match(regex)).sort();

    const finalResult = isCustomize
      ? customize(resultList)
      : resultList;

    return completeFromList(finalResult as string[]);

I think the problem is that you are creating a new function on every languagedata query, which prevents the autocompletion from recognizing that this is the same completion source. Moving the object creation out of the languagedata source might help.

const customCompletion = { autocomplete: myCompletions(customList) }
EditorState.languageData.of(() => [customCompletion])

thank you! but unfortunately, using

return completeFromList(finalResult as string[]);

to get a completion source causes an error when typing :frowning: