Fix stale data in tippy

This commit is contained in:
Jon Staab 2026-07-03 16:48:23 -07:00
parent 99abe17151
commit e36f2d995e

View file

@ -17,6 +17,15 @@
let element: Element 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(() => { onMount(() => {
const target = document.createElement("div") const target = document.createElement("div")
@ -28,7 +37,7 @@
...params, ...params,
}) })
instance = mount(component, {target, props}) instance = mount(component, {target, props: mountedProps})
return () => { return () => {
popover?.destroy() popover?.destroy()