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

View File

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

View File

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