Skip to content

Commit 0f833cb

Browse files
committed
fix: trigger multipe click #5002
本质原因应该还是 vue 问题,有待进一步定位
1 parent 9c0464d commit 0f833cb

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

components/dropdown/dropdown-button.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ export default defineComponent({
2323
emits: ['click', 'visibleChange', 'update:visible'],
2424
slots: ['icon', 'leftButton', 'rightButton', 'overlay'],
2525
setup(props, { slots, attrs, emit }) {
26-
const handleClick = (e: MouseEvent) => {
27-
emit('click', e);
28-
};
2926
const handleVisibleChange = (val: boolean) => {
3027
emit('update:visible', val);
3128
emit('visibleChange', val);
@@ -43,13 +40,15 @@ export default defineComponent({
4340
trigger,
4441
align,
4542
visible,
46-
onVisibleChange,
43+
onVisibleChange: _onVisibleChange,
4744
placement = direction.value === 'rtl' ? 'bottomLeft' : 'bottomRight',
4845
href,
4946
title,
5047
icon = slots.icon?.() || <EllipsisOutlined />,
5148
mouseEnterDelay,
5249
mouseLeaveDelay,
50+
onClick,
51+
'onUpdate:visible': _updateVisible,
5352
...restProps
5453
} = { ...props, ...attrs };
5554

@@ -69,7 +68,7 @@ export default defineComponent({
6968
<Button
7069
type={type}
7170
disabled={disabled}
72-
onClick={handleClick}
71+
onClick={onClick}
7372
htmlType={htmlType}
7473
href={href}
7574
title={title}

components/dropdown/dropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const Dropdown = defineComponent({
135135
onVisibleChange: handleVisibleChange,
136136
placement: placement.value,
137137
},
138-
['overlay'],
138+
['overlay', 'onUpdate:visible'],
139139
);
140140
return (
141141
<RcDropdown {...dropdownProps} v-slots={{ overlay: renderOverlay }}>

components/dropdown/props.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { PropType } from 'vue';
33
import PropTypes from '../_util/vue-types';
44

55
import buttonTypes from '../button/buttonTypes';
6+
import type { MouseEventHandler } from '../_util/EventInterface';
67

78
type Align = {
89
points?: [string, string];
@@ -40,6 +41,12 @@ const dropdownProps = () => ({
4041
mouseLeaveDelay: PropTypes.number,
4142
openClassName: PropTypes.string,
4243
minOverlayWidthMatchTrigger: PropTypes.looseBool,
44+
onVisibleChange: {
45+
type: Function as PropType<(val: boolean) => void>,
46+
},
47+
'onUpdate:visible': {
48+
type: Function as PropType<(val: boolean) => void>,
49+
},
4350
});
4451

4552
const ButtonTypesProps = buttonTypes();
@@ -53,6 +60,9 @@ const dropdownButtonProps = () => ({
5360
prefixCls: PropTypes.string,
5461
icon: PropTypes.any,
5562
title: PropTypes.string,
63+
onClick: {
64+
type: Function as PropType<MouseEventHandler>,
65+
},
5666
});
5767

5868
export { dropdownProps, dropdownButtonProps };

0 commit comments

Comments
 (0)