Skip to content

Commit 1e86019

Browse files
committed
fix: menu trigger twice click #2266
1 parent 4cc762d commit 1e86019

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

components/vc-menu/DOMWrap.jsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const DOMWrap = {
112112
// with a title of overflow indicator ('...')
113113
const copy = this.$slots.default[0];
114114
const { title, ...rest } = getPropsData(copy); // eslint-disable-line no-unused-vars
115-
115+
const events = getEvents(copy);
116116
let style = {};
117117
let key = `${keyPrefix}-overflowed-indicator`;
118118
let eventKey = `${keyPrefix}-overflowed-indicator`;
@@ -133,11 +133,17 @@ const DOMWrap = {
133133

134134
const popupClassName = theme ? `${prefixCls}-${theme}` : '';
135135
const props = {};
136+
const on = {};
136137
menuAllProps.props.forEach(k => {
137138
if (rest[k] !== undefined) {
138139
props[k] = rest[k];
139140
}
140141
});
142+
menuAllProps.on.forEach(k => {
143+
if (events[k] !== undefined) {
144+
on[k] = events[k];
145+
}
146+
});
141147
const subMenuProps = {
142148
props: {
143149
title: overflowedIndicator,
@@ -149,7 +155,7 @@ const DOMWrap = {
149155
class: `${prefixCls}-overflowed-submenu`,
150156
key,
151157
style,
152-
on: getEvents(copy),
158+
on,
153159
};
154160

155161
return <SubMenu {...subMenuProps}>{overflowedItems}</SubMenu>;
@@ -263,7 +269,10 @@ const DOMWrap = {
263269
c,
264270
// children[index].key will become '.$key' in clone by default,
265271
// we have to overwrite with the correct key explicitly
266-
{ key: getPropsData(c).eventKey, props: { mode: 'vertical-left' } },
272+
{
273+
key: getPropsData(c).eventKey,
274+
props: { mode: 'vertical-left' },
275+
},
267276
);
268277
});
269278

components/vc-menu/SubPopupMenu.jsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,8 @@ const SubPopupMenu = {
337337
},
338338
on: {
339339
click: e => {
340-
if ('keyPath' in e) {
341-
(childListeners.click || noop)(e);
342-
this.onClick(e);
343-
}
340+
(childListeners.click || noop)(e);
341+
this.onClick(e);
344342
},
345343
itemHover: this.onItemHover,
346344
openChange: this.onOpenChange,

0 commit comments

Comments
 (0)