Skip to content

Commit

Permalink
fix: tooltip confirmOption (#85)
Browse files Browse the repository at this point in the history
Co-authored-by: aringlai <aringlai@webank.com>
  • Loading branch information
aringlai and aringlai committed Mar 28, 2022
1 parent c5eac7f commit 4ff779b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default defineComponent({
};
}

function handleConfirmCB(name: typeof OK_EVENT | typeof CANCEL_EVENT, event: MouseEvent) {
function handleConfirmCB(
name: typeof OK_EVENT | typeof CANCEL_EVENT,
event: MouseEvent,
) {
updateCurrentValue(false);
ctx.emit(name, event);
}
Expand All @@ -74,8 +77,8 @@ export default defineComponent({
}
if (isConfirm || isPopover) {
const mergeOpt = {
...props.confirmOption,
...defaultConfirmOption,
...props.confirmOption,
};
const contentClass = [
`${prefixCls}-modal-body`,
Expand All @@ -88,8 +91,9 @@ export default defineComponent({
<>
{title && (
<div
class={`${prefixCls}-modal-header ${isConfirm && 'is-confirm'
}`}
class={`${prefixCls}-modal-header ${
isConfirm && 'is-confirm'
}`}
>
{isConfirm && (
<div class={`${prefixCls}-modal-icon`}>
Expand Down Expand Up @@ -130,7 +134,9 @@ export default defineComponent({

return () => {
const _props = { ...props };
tooltipPropKeys.forEach((key) => delete _props[key as keyof typeof toolTipProps]);
tooltipPropKeys.forEach(
(key) => delete _props[key as keyof typeof toolTipProps],
);
if (props.mode === 'confirm') {
// confirm模式下,只能点击触发
_props.trigger = 'click';
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/components/tooltip/confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Space>
<FTooltip
mode="confirm"
:confirmOption="{ okText: 'OK' }"
@ok="() => handleConfirm('确定')"
@cancel="() => handleConfirm('取消')"
>
Expand Down

0 comments on commit 4ff779b

Please sign in to comment.