Sometimes the autocomplete overlay remains open even if the parent view is destroyed.
I managed to resolve that by adding the destroy callback in decoration.ts, but it doesn't seem like the right way to do it.
destroy: () => {
reducer({ kind: ActionKind.close, view: null, trigger: null, range: null, filter: null, type: null });
},
update: (view, prevState) => {
const prev = plugin.getState(prevState) as ActiveAutocompleteState;
const next = plugin.getState(view.state) as ActiveAutocompleteState;
const started = !prev.active && next.active;
const stopped = prev.active && !next.active;
const changed = next.active && !started && !stopped && prev.filter !== next.filter;
const action: Omit<AutocompleteAction, 'kind'> = {
view,
trigger: next.trigger ?? (prev.trigger as string),
filter: next.filter ?? prev.filter,
range: next.range ?? (prev.range as FromTo),
type: next.type ?? prev.type,
};
if (started) reducer({ ...action, kind: ActionKind.open });
if (changed) reducer({ ...action, kind: ActionKind.filter });
if (stopped) reducer({ ...action, kind: ActionKind.close });
}
If this does seem ok, I'll create a PR.
Sometimes the autocomplete overlay remains open even if the parent view is destroyed.
I managed to resolve that by adding the
destroycallback indecoration.ts, but it doesn't seem like the right way to do it.If this does seem ok, I'll create a PR.