From ab8768b19b3dbd0a76867827446d7c3bc0ccca69 Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Wed, 26 Feb 2020 20:20:35 +0800
Subject: [PATCH] feat: update tooltip
---
build/config.js | 2 +-
components/tooltip/Tooltip.jsx | 21 +++++++++++++++-----
components/tooltip/__tests__/tooltip.test.js | 2 ++
components/tooltip/demo/index.vue | 15 ++++++--------
components/tooltip/demo/placement.md | 2 +-
site/components/demoSort.jsx | 2 +-
6 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/build/config.js b/build/config.js
index 68fd72401..622e99787 100644
--- a/build/config.js
+++ b/build/config.js
@@ -1,5 +1,5 @@
module.exports = {
dev: {
- componentName: 'tag', // dev components
+ componentName: 'tooltip', // dev components
},
};
diff --git a/components/tooltip/Tooltip.jsx b/components/tooltip/Tooltip.jsx
index dcf427622..fe94edd65 100644
--- a/components/tooltip/Tooltip.jsx
+++ b/components/tooltip/Tooltip.jsx
@@ -78,9 +78,12 @@ export default {
// mouse events don't trigger at disabled button in Chrome
// https://github.com/react-component/tooltip/issues/18
getDisabledCompatibleChildren(ele) {
- const isAntBtn = ele.componentOptions && ele.componentOptions.Ctor.options.__ANT_BUTTON;
+ const options = (ele.componentOptions && ele.componentOptions.Ctor.options) || {};
+
if (
- (isAntBtn &&
+ ((options.__ANT_BUTTON === true ||
+ options.__ANT_SWITCH === true ||
+ options.__ANT_CHECKBOX === true) &&
(ele.componentOptions.propsData.disabled ||
ele.componentOptions.propsData.disabled === '')) ||
(ele.tag === 'button' &&
@@ -125,8 +128,16 @@ export default {
},
isNoTitle() {
- const { $slots, title } = this;
- return !$slots.title && !title;
+ const title = getComponentFromProp(this, 'title');
+ return !title && title !== 0;
+ },
+
+ getOverlay() {
+ const title = getComponentFromProp(this, 'title');
+ if (title === 0) {
+ return title;
+ }
+ return title || '';
},
// 动态设置动画点
@@ -189,6 +200,7 @@ export default {
prefixCls,
getTooltipContainer: getPopupContainer || getContextPopupContainer,
builtinPlacements: this.getPlacements(),
+ overlay: this.getOverlay(),
visible: sVisible,
},
ref: 'tooltip',
@@ -200,7 +212,6 @@ export default {
};
return (