Skip to content

Commit ab8768b

Browse files
committed
feat: update tooltip
1 parent 05658b7 commit ab8768b

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

build/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
dev: {
3-
componentName: 'tag', // dev components
3+
componentName: 'tooltip', // dev components
44
},
55
};

components/tooltip/Tooltip.jsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ export default {
7878
// mouse events don't trigger at disabled button in Chrome
7979
// https://github.com/react-component/tooltip/issues/18
8080
getDisabledCompatibleChildren(ele) {
81-
const isAntBtn = ele.componentOptions && ele.componentOptions.Ctor.options.__ANT_BUTTON;
81+
const options = (ele.componentOptions && ele.componentOptions.Ctor.options) || {};
82+
8283
if (
83-
(isAntBtn &&
84+
((options.__ANT_BUTTON === true ||
85+
options.__ANT_SWITCH === true ||
86+
options.__ANT_CHECKBOX === true) &&
8487
(ele.componentOptions.propsData.disabled ||
8588
ele.componentOptions.propsData.disabled === '')) ||
8689
(ele.tag === 'button' &&
@@ -125,8 +128,16 @@ export default {
125128
},
126129

127130
isNoTitle() {
128-
const { $slots, title } = this;
129-
return !$slots.title && !title;
131+
const title = getComponentFromProp(this, 'title');
132+
return !title && title !== 0;
133+
},
134+
135+
getOverlay() {
136+
const title = getComponentFromProp(this, 'title');
137+
if (title === 0) {
138+
return title;
139+
}
140+
return title || '';
130141
},
131142

132143
// 动态设置动画点
@@ -189,6 +200,7 @@ export default {
189200
prefixCls,
190201
getTooltipContainer: getPopupContainer || getContextPopupContainer,
191202
builtinPlacements: this.getPlacements(),
203+
overlay: this.getOverlay(),
192204
visible: sVisible,
193205
},
194206
ref: 'tooltip',
@@ -200,7 +212,6 @@ export default {
200212
};
201213
return (
202214
<VcTooltip {...tooltipProps}>
203-
<template slot="overlay">{getComponentFromProp(this, 'title')}</template>
204215
{sVisible ? cloneElement(child, { class: childCls }) : child}
205216
</VcTooltip>
206217
);

components/tooltip/__tests__/tooltip.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { asyncExpect } from '@/tests/utils';
22
import { mount } from '@vue/test-utils';
33
import Tooltip from '..';
4+
import mountTest from '../../../tests/shared/mountTest';
45

56
describe('Tooltip', () => {
7+
mountTest(Tooltip);
68
it('check `onVisibleChange` arguments', async () => {
79
const onVisibleChange = jest.fn();
810
const wrapper = mount(

components/tooltip/demo/index.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ export default {
3737
return (
3838
<div>
3939
<md cn={md.cn} us={md.us} />
40-
<br />
41-
<Basic />
42-
<br />
43-
<Placement />
44-
<br />
45-
<ArrowPointAtCenter />
46-
<br />
47-
<AutoAdjustOverflow />
48-
<br />
40+
<demo-sort cols="2">
41+
<Basic />
42+
<Placement />
43+
<ArrowPointAtCenter />
44+
<AutoAdjustOverflow />
45+
</demo-sort>
4946
<api>
5047
<template slot="cn">
5148
<CN />

components/tooltip/demo/placement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<us>
77
#### Placement
8-
The ToolTip has 12 placements choice.
8+
There are 12 placement options available.
99
</us>
1010

1111
```tpl

site/components/demoSort.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
props: {
1212
cols: {
1313
type: [Number, String],
14-
default: 1,
14+
default: 2,
1515
},
1616
},
1717
inject: {

0 commit comments

Comments
 (0)