Skip to content
Snippets Groups Projects
Commit a53a48dd authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

fix: don’t override locally defined slots

parent e661752f
No related branches found
No related tags found
No related merge requests found
...@@ -24,15 +24,15 @@ ...@@ -24,15 +24,15 @@
</slot> </slot>
</template> </template>
<template v-for="(_, name) in slots" #[name]="slotProps"> <template v-for="name in foreignSlotNames" #[name]="slotProps">
<slot :name="name" v-bind="slotProps || {}" /> <slot :name="name" v-bind="slotProps || {}" />
</template> </template>
</ADialog> </ADialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, useSlots } from 'vue' import { ref } from 'vue'
import { useI18n } from '@/i18n' import { useI18n } from '@/i18n'
import { useId } from '@/util' import { useForeignSlotNames, useId } from '@/util'
import ADialog from '@/components/generic/ADialog.vue' import ADialog from '@/components/generic/ADialog.vue'
import Loading from '@/components/generic/Loading.vue' import Loading from '@/components/generic/Loading.vue'
...@@ -53,7 +53,7 @@ const props = withDefaults( ...@@ -53,7 +53,7 @@ const props = withDefaults(
}, },
) )
const slots = useSlots() const foreignSlotNames = useForeignSlotNames()
const { t } = useI18n() const { t } = useI18n()
const id = useId('dialog-form') const id = useId('dialog-form')
const dialog = ref() const dialog = ref()
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
shallowRef, shallowRef,
toRef, toRef,
toValue, toValue,
useSlots,
watch, watch,
watchEffect, watchEffect,
} from 'vue' } from 'vue'
...@@ -327,3 +328,12 @@ export function parseTime(time: string): number { ...@@ -327,3 +328,12 @@ export function parseTime(time: string): number {
parseInt(seconds || 0) parseInt(seconds || 0)
) )
} }
export function useForeignSlotNames() {
const slots = useSlots()
return computed(() => {
return Object.entries(slots)
.filter(([, slot]) => slot && slot.name === '')
.map(([key]) => key)
})
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment