Skip to content

Commit

Permalink
Fix for NumberFlowGroup and v-if
Browse files Browse the repository at this point in the history
  • Loading branch information
barvian committed Nov 14, 2024
1 parent 6f164d5 commit a57700c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/dry-pianos-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'number-flow': patch
'@number-flow/vue': patch
---

Fix for `<NumberFlowGroup>` and v-if
4 changes: 4 additions & 0 deletions packages/number-flow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export class NumberFlowLite extends ServerSafeHTMLElement implements Props {
}

#created = false
get created() {
return this.#created
}

#pre?: SymbolSection
#num?: Num
#post?: SymbolSection
Expand Down
11 changes: 6 additions & 5 deletions packages/vue/src/NumberFlowGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ const registerWithGroup: RegisterWithGroup = (el, parts) => {
async () => {
if (updating) return
updating = true
flows.forEach((flow) => {
flow.value?.willUpdate()
})
await nextTick()
flows.forEach((flow) => {
flows.forEach(async (flow) => {
if (!flow.value || !flow.value.created) return
flow.value.willUpdate()
await nextTick()
// Optional in case the element was removed after tick:
flow.value?.didUpdate()
})
await nextTick()
updating = false
}
// { flush: 'pre' } // default
Expand Down

0 comments on commit a57700c

Please sign in to comment.