Skip to content

Commit 0492be9

Browse files
committed
fix: CDropdownItem: fix closing dropdown when item is router link #79
1 parent 4c29500 commit 0492be9

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/components/dropdown/CDropdownItem.vue

+22-13
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,30 @@ export default {
55
name: 'CDropdownItem',
66
props: propsFactory(),
77
render (h) {
8+
const data = {
9+
props: this._props,
10+
staticClass: 'dropdown-item',
11+
attrs: { role: 'menuitem' },
12+
on: {
13+
//listeners added, due to component was previously functional for compatibility
14+
...this.$listeners,
15+
click: (e) => {
16+
this.$parent.$emit('dropdown-close')
17+
this.$emit('click', e)
18+
}
19+
}
20+
}
21+
if (this.to) {
22+
data.nativeOn = {
23+
click: (e) => {
24+
this.$parent.$emit('dropdown-close')
25+
this.$emit('click', e)
26+
}
27+
}
28+
}
829
return h(
930
CLink,
10-
{
11-
props: this._props,
12-
staticClass: 'dropdown-item',
13-
attrs: { role: 'menuitem' },
14-
on: {
15-
//listeners added, due to component was previously functional for compatibility
16-
...this.$listeners,
17-
click: (e) => {
18-
this.$parent.$emit('dropdown-close')
19-
this.$emit('click', e)
20-
}
21-
}
22-
},
31+
data,
2332
this.$slots.default
2433
)
2534
}

0 commit comments

Comments
 (0)