fix: Fix memory leaking in MentionList.svelte (#21965)

This commit is contained in:
Shirasawa authored and GitHub committed 2026-02-28 21:48:56 -06:00
1 parent e83f668107
commit 39b87d9683
1 file changed
+6 -5
@@ -98,7 +98,8 @@
return onKeyDown(event);
}
const keydownListener = (e) => {
onMount(() => {
const keydownListener = (e: KeyboardEvent) => {
// required to prevent the default enter behavior
if (e.key === 'Enter') {
e.preventDefault();
@@ -106,8 +107,8 @@
}
};
onMount(async () => {
window.addEventListener('keydown', keydownListener);
if (channelSuggestions) {
// Add a dummy channel item
_channels = [
@@ -117,17 +118,17 @@
];
} else {
if (userSuggestions) {
await getUserList();
getUserList();
}
if (modelSuggestions) {
_models = [...$models.map((m) => ({ type: 'model', id: m.id, label: m.name, data: m }))];
}
}
});
onDestroy(() => {
return () => {
window.removeEventListener('keydown', keydownListener);
};
});
const hasPublicReadGrant = (grants: any) =>