Skip to content

Commit

Permalink
fix(collapsible): nuxt refresh page error (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Jul 19, 2023
1 parent fb33249 commit 1ae2e0a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/components/collapsible/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@oku-ui/collapsible",
"type": "module",
"version": "0.2.3",
"version": "0.2.4",
"license": "MIT",
"source": "src/index.ts",
"funding": "https://github.com/sponsors/productdevbook",
Expand Down
10 changes: 6 additions & 4 deletions packages/components/collapsible/src/collapsibleContentImpl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PropType, Ref } from 'vue'
import { computed, defineComponent, h, nextTick, ref, toRefs, watch, watchEffect } from 'vue'
import { computed, defineComponent, h, nextTick, onMounted, ref, toRefs, watch, watchEffect } from 'vue'
import type { ElementType, MergeProps, PrimitiveProps, RefElement } from '@oku-ui/primitive'
import type { Scope } from '@oku-ui/provide'
import { Primitive } from '@oku-ui/primitive'
Expand Down Expand Up @@ -46,9 +46,11 @@ const CollapsibleContentImpl = defineComponent({
const isMountAnimationPreventedRef = ref(isOpen.value)
const originalStylesRef = ref<Record<string, string>>()

watchEffect(async (onCleanup) => {
const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.value = false))
onCleanup(() => cancelAnimationFrame(rAF))
onMounted(() => {
watchEffect(async (onCleanup) => {
const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.value = false))
onCleanup(() => cancelAnimationFrame(rAF))
})
})

watch([isOpen, isPresent], async () => {
Expand Down
1 change: 1 addition & 0 deletions playground/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@oku-ui/aspect-ratio": "workspace:^",
"@oku-ui/avatar": "workspace:^",
"@oku-ui/checkbox": "workspace:^",
"@oku-ui/collapsible": "workspace:^",
"@oku-ui/label": "workspace:^",
"@oku-ui/progress": "workspace:^",
"@oku-ui/separator": "workspace:^"
Expand Down
5 changes: 5 additions & 0 deletions playground/nuxt3/pages/collapsible.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<CollapsibleDemo allshow />
</div>
</template>
4 changes: 4 additions & 0 deletions playground/nuxt3/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const pages: Page[] = [
name: 'OkuPopper',
path: '/popper',
},
{
name: 'OkuCollapsible',
path: '/collapsible',
},
]
</script>

Expand Down
7 changes: 5 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ae2e0a

Please sign in to comment.