fix: menu trigger twice click #2266

This commit is contained in:
tanjinzhou 2020-05-20 17:29:06 +08:00
parent 4cc762d6cb
commit 1e86019ceb
2 changed files with 14 additions and 7 deletions

View File

@ -112,7 +112,7 @@ const DOMWrap = {
// with a title of overflow indicator ('...') // with a title of overflow indicator ('...')
const copy = this.$slots.default[0]; const copy = this.$slots.default[0];
const { title, ...rest } = getPropsData(copy); // eslint-disable-line no-unused-vars const { title, ...rest } = getPropsData(copy); // eslint-disable-line no-unused-vars
const events = getEvents(copy);
let style = {}; let style = {};
let key = `${keyPrefix}-overflowed-indicator`; let key = `${keyPrefix}-overflowed-indicator`;
let eventKey = `${keyPrefix}-overflowed-indicator`; let eventKey = `${keyPrefix}-overflowed-indicator`;
@ -133,11 +133,17 @@ const DOMWrap = {
const popupClassName = theme ? `${prefixCls}-${theme}` : ''; const popupClassName = theme ? `${prefixCls}-${theme}` : '';
const props = {}; const props = {};
const on = {};
menuAllProps.props.forEach(k => { menuAllProps.props.forEach(k => {
if (rest[k] !== undefined) { if (rest[k] !== undefined) {
props[k] = rest[k]; props[k] = rest[k];
} }
}); });
menuAllProps.on.forEach(k => {
if (events[k] !== undefined) {
on[k] = events[k];
}
});
const subMenuProps = { const subMenuProps = {
props: { props: {
title: overflowedIndicator, title: overflowedIndicator,
@ -149,7 +155,7 @@ const DOMWrap = {
class: `${prefixCls}-overflowed-submenu`, class: `${prefixCls}-overflowed-submenu`,
key, key,
style, style,
on: getEvents(copy), on,
}; };
return <SubMenu {...subMenuProps}>{overflowedItems}</SubMenu>; return <SubMenu {...subMenuProps}>{overflowedItems}</SubMenu>;
@ -263,7 +269,10 @@ const DOMWrap = {
c, c,
// children[index].key will become '.$key' in clone by default, // children[index].key will become '.$key' in clone by default,
// we have to overwrite with the correct key explicitly // we have to overwrite with the correct key explicitly
{ key: getPropsData(c).eventKey, props: { mode: 'vertical-left' } }, {
key: getPropsData(c).eventKey,
props: { mode: 'vertical-left' },
},
); );
}); });

View File

@ -337,10 +337,8 @@ const SubPopupMenu = {
}, },
on: { on: {
click: e => { click: e => {
if ('keyPath' in e) {
(childListeners.click || noop)(e); (childListeners.click || noop)(e);
this.onClick(e); this.onClick(e);
}
}, },
itemHover: this.onItemHover, itemHover: this.onItemHover,
openChange: this.onOpenChange, openChange: this.onOpenChange,