Skip to content

Commit

Permalink
fix(pop-confirm): fix event working unexpected
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan committed Jun 24, 2021
1 parent 4d8e398 commit a6ef771
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **Table** 修复分页抖动问题
- **Upload** 确保携带自定义参数
- **Dropdown** 修复 popConfirm 的图标显示问题

## 2.5.0(2021-06-20)

Expand Down
21 changes: 18 additions & 3 deletions src/components/Dropdown/src/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
@click="handleClickMenu(item)"
:disabled="item.disabled"
>
<Popconfirm v-if="popconfirm && item.popConfirm" v-bind="omit(item.popConfirm, 'icon')">
<Popconfirm
v-if="popconfirm && item.popConfirm"
v-bind="getPopConfirmAttrs(item.popConfirm)"
>
<template #icon v-if="item.popConfirm.icon">
<Icon :icon="item.popConfirm.icon" />
</template>
Expand All @@ -33,13 +36,14 @@
</template>

<script lang="ts">
import type { PropType } from 'vue';
import { computed, PropType } from 'vue';
import type { DropMenu } from './typing';
import { defineComponent } from 'vue';
import { Dropdown, Menu, Popconfirm } from 'ant-design-vue';
import { Icon } from '/@/components/Icon';
import { omit } from 'lodash-es';
import { isFunction } from '/@/utils/is';
export default defineComponent({
name: 'BasicDropdown',
Expand Down Expand Up @@ -82,9 +86,20 @@
item.onClick?.();
}
const getPopConfirmAttrs = computed(() => {
return (attrs) => {
const originAttrs = omit(attrs, ['confirm', 'cancel', 'icon']);
if (!attrs.onConfirm && attrs.confirm && isFunction(attrs.confirm))
originAttrs['onConfirm'] = attrs.confirm;
if (!attrs.onCancel && attrs.cancel && isFunction(attrs.cancel))
originAttrs['onCancel'] = attrs.cancel;
return originAttrs;
};
});
return {
handleClickMenu,
omit,
getPopConfirmAttrs,
getAttr: (key: string | number) => ({ key }),
};
},
Expand Down

0 comments on commit a6ef771

Please sign in to comment.