diff --git a/src/lib/components/Tippy.svelte b/src/lib/components/Tippy.svelte index 82919022..a00934f9 100644 --- a/src/lib/components/Tippy.svelte +++ b/src/lib/components/Tippy.svelte @@ -17,6 +17,15 @@ let element: Element + // `mount` only tracks prop changes when the props come from a `$state` object, + // so sync incoming props into a reactive one. Without this the popover keeps + // the props it was first mounted with, showing stale data after the source updates. + const mountedProps = $state({...props}) + + $effect(() => { + Object.assign(mountedProps, props) + }) + onMount(() => { const target = document.createElement("div") @@ -28,7 +37,7 @@ ...params, }) - instance = mount(component, {target, props}) + instance = mount(component, {target, props: mountedProps}) return () => { popover?.destroy()