Fix stale data in tippy
This commit is contained in:
parent
99abe17151
commit
e36f2d995e
1 changed files with 10 additions and 1 deletions
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue