Skip to content

Commit 56b8ae0

Browse files
committed
refactor: update events
1 parent f3778b0 commit 56b8ae0

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/components/nav/CNavGroup.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const CNavGroup = defineComponent({
1616
required: false,
1717
},
1818
},
19-
emits: ['visibleChange'],
20-
setup(props, { emit, slots }) {
19+
emits: ['visible-change'],
20+
setup(props, { slots, emit }) {
2121
const visible = ref(props.visible)
2222
const navGroupRef = ref()
2323

@@ -49,7 +49,7 @@ const CNavGroup = defineComponent({
4949

5050
const handleTogglerClick = function () {
5151
visible.value = !visible.value
52-
emit('visibleChange', visible.value)
52+
emit('visible-change', visible.value)
5353
}
5454
const handleBeforeEnter = (el: RendererElement) => {
5555
el.style.height = '0px'
@@ -121,12 +121,17 @@ const CNavGroup = defineComponent({
121121
],
122122
},
123123
slots.default &&
124-
slots.default().map((vnode, index) =>
125-
h(vnode, {
126-
onVisibleChange: (visible: boolean) => handleVisibleChange(visible, index),
127-
visible: isVisible(index),
128-
}),
129-
),
124+
slots.default().map((vnode, index) => {
125+
// @ts-expect-error name is defined in component
126+
if (vnode.type.name === 'CNavGroup') {
127+
return h(vnode, {
128+
onVisibleChange: (visible: boolean) =>
129+
handleVisibleChange(visible, index),
130+
visible: isVisible(index),
131+
})
132+
}
133+
return vnode
134+
}),
130135
),
131136
},
132137
),

0 commit comments

Comments
 (0)