Skip to content

Commit

Permalink
fix(vue): fix close accordion example
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed Apr 28, 2024
1 parent f5942a8 commit 302e8f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Vertical from './examples/vertical.vue'
<Disabled />
</Variant>
<Variant title="Closed">
<Accordion :items="['React', 'Solid', 'Vue']" />
<Accordion multiple :items="['React', 'Solid', 'Vue']" />
</Variant>
</Story>
</template>
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<script setup lang="ts">
import { Accordion, type AccordionRootEmits, type AccordionRootProps } from '../'
import { useForwardPropsEmits } from '../../../utils'
import { ChevronDownIcon } from './icons'
export interface AccordionProps extends AccordionRootProps {
items: string[]
}
defineProps<AccordionProps>()
const props = defineProps<AccordionProps>()
const emits = defineEmits<AccordionRootEmits>()
const forwarded = useForwardPropsEmits(props, emits)
</script>

<template>
<Accordion.Root>
<Accordion.Root v-bind="forwarded">
<Accordion.Item v-for="item in items" :key="item" :value="item">
<Accordion.ItemTrigger>
What is {{ item }}?
Expand Down
5 changes: 3 additions & 2 deletions frameworks/vue/src/utils/use-forward-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ export function useForwardProps<
const preservedProps = {} as U
const assignedProps = vm?.vnode.props ?? {}

for (const key in Object.keys(assignedProps)) {
// biome-ignore lint/complexity/noForEach: <explanation>
Object.keys(assignedProps).forEach((key) => {
preservedProps[camelize(key) as keyof U] = assignedProps[key]
}
})

// @ts-expect-error
return Object.keys({ ...defaultProps, ...preservedProps }).reduce((prev, curr) => {
Expand Down

0 comments on commit 302e8f0

Please sign in to comment.