Skip to content

Commit 25e8f3b

Browse files
HugoRCDbenjamincanac
authored andcommitted
fix(ProseImg): ensure unique motion layout id for images (#4720)
1 parent 0f73480 commit 25e8f3b

File tree

1 file changed

+5
-3
lines changed
  • src/runtime/components/prose

1 file changed

+5
-3
lines changed

src/runtime/components/prose/Img.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface ProseImgProps {
2121
</script>
2222

2323
<script setup lang="ts">
24-
import { ref, computed } from 'vue'
24+
import { ref, computed, useId } from 'vue'
2525
import { withTrailingSlash, withLeadingSlash, joinURL } from 'ufo'
2626
import { DialogRoot, DialogPortal, DialogTrigger } from 'reka-ui'
2727
import { AnimatePresence, Motion } from 'motion-v'
@@ -57,6 +57,8 @@ const refinedSrc = computed(() => {
5757
return props.src
5858
})
5959
60+
const layoutId = computed(() => `${refinedSrc.value}::${useId()}`)
61+
6062
if (props.zoom) {
6163
useEventListener(window, 'scroll', () => {
6264
open.value = false
@@ -79,7 +81,7 @@ if (props.zoom) {
7981

8082
<DialogRoot v-if="zoom" v-slot="{ close }" v-model:open="open" :modal="false">
8183
<DialogTrigger as-child>
82-
<Motion :layout-id="refinedSrc" as-child :transition="{ type: 'spring', bounce: 0.2, duration: 0.4 }">
84+
<Motion :layout-id="layoutId" as-child :transition="{ type: 'spring', bounce: 0.2, duration: 0.4 }">
8385
<ReuseImageTemplate />
8486
</Motion>
8587
</DialogTrigger>
@@ -89,7 +91,7 @@ if (props.zoom) {
8991
<Motion v-if="open" :initial="{ opacity: 0 }" :animate="{ opacity: 1 }" :exit="{ opacity: 0 }" :class="ui.overlay({ class: [props.ui?.overlay] })" />
9092

9193
<div v-if="open" :class="ui.content({ class: [props.ui?.content] })" @click="close">
92-
<Motion as-child :layout-id="refinedSrc" :transition="{ type: 'spring', bounce: 0.2, duration: 0.4 }">
94+
<Motion as-child :layout-id="layoutId" :transition="{ type: 'spring', bounce: 0.2, duration: 0.4 }">
9395
<ReuseImageTemplate />
9496
</Motion>
9597
</div>

0 commit comments

Comments
 (0)