fix: trigger multipe click #5002

本质原因应该还是 vue 问题,有待进一步定位
pull/5026/head
tangjinzhou 2021-12-11 22:41:01 +08:00
parent 9c0464d072
commit 0f833cb536
3 changed files with 15 additions and 6 deletions

View File

@ -23,9 +23,6 @@ export default defineComponent({
emits: ['click', 'visibleChange', 'update:visible'],
slots: ['icon', 'leftButton', 'rightButton', 'overlay'],
setup(props, { slots, attrs, emit }) {
const handleClick = (e: MouseEvent) => {
emit('click', e);
};
const handleVisibleChange = (val: boolean) => {
emit('update:visible', val);
emit('visibleChange', val);
@ -43,13 +40,15 @@ export default defineComponent({
trigger,
align,
visible,
onVisibleChange,
onVisibleChange: _onVisibleChange,
placement = direction.value === 'rtl' ? 'bottomLeft' : 'bottomRight',
href,
title,
icon = slots.icon?.() || <EllipsisOutlined />,
mouseEnterDelay,
mouseLeaveDelay,
onClick,
'onUpdate:visible': _updateVisible,
...restProps
} = { ...props, ...attrs };
@ -69,7 +68,7 @@ export default defineComponent({
<Button
type={type}
disabled={disabled}
onClick={handleClick}
onClick={onClick}
htmlType={htmlType}
href={href}
title={title}

View File

@ -135,7 +135,7 @@ const Dropdown = defineComponent({
onVisibleChange: handleVisibleChange,
placement: placement.value,
},
['overlay'],
['overlay', 'onUpdate:visible'],
);
return (
<RcDropdown {...dropdownProps} v-slots={{ overlay: renderOverlay }}>

View File

@ -3,6 +3,7 @@ import type { PropType } from 'vue';
import PropTypes from '../_util/vue-types';
import buttonTypes from '../button/buttonTypes';
import type { MouseEventHandler } from '../_util/EventInterface';
type Align = {
points?: [string, string];
@ -40,6 +41,12 @@ const dropdownProps = () => ({
mouseLeaveDelay: PropTypes.number,
openClassName: PropTypes.string,
minOverlayWidthMatchTrigger: PropTypes.looseBool,
onVisibleChange: {
type: Function as PropType<(val: boolean) => void>,
},
'onUpdate:visible': {
type: Function as PropType<(val: boolean) => void>,
},
});
const ButtonTypesProps = buttonTypes();
@ -53,6 +60,9 @@ const dropdownButtonProps = () => ({
prefixCls: PropTypes.string,
icon: PropTypes.any,
title: PropTypes.string,
onClick: {
type: Function as PropType<MouseEventHandler>,
},
});
export { dropdownProps, dropdownButtonProps };