From 4fc2e204e865ffc78ac1530fa0a2c61f7f28216d Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 27 Oct 2025 15:06:53 -0700 Subject: [PATCH] refac/chore: svelte 5 migration --- src/lib/components/common/RichTextInput/suggestions.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/components/common/RichTextInput/suggestions.ts b/src/lib/components/common/RichTextInput/suggestions.ts index a87b95abf9..0667e83060 100644 --- a/src/lib/components/common/RichTextInput/suggestions.ts +++ b/src/lib/components/common/RichTextInput/suggestions.ts @@ -1,3 +1,4 @@ +import { mount, unmount } from 'svelte'; import tippy from 'tippy.js'; export function getSuggestionRenderer(Component: any, ComponentProps = {}) { @@ -15,7 +16,7 @@ export function getSuggestionRenderer(Component: any, ComponentProps = {}) { document.body.appendChild(container); // mount Svelte component - component = new Component({ + component = mount(Component, { target: container, props: { char: props?.text, @@ -104,7 +105,12 @@ export function getSuggestionRenderer(Component: any, ComponentProps = {}) { popup?.destroy(); popup = null; - component?.$destroy(); + try { + unmount(component); + } catch (e) { + console.error('Error unmounting component:', e); + } + component = null; if (container?.parentNode) container.parentNode.removeChild(container);