From 2e1c19471e199e862cec0216c67128862b73160f Mon Sep 17 00:00:00 2001 From: tjz <415800467@qq.com> Date: Tue, 17 Jul 2018 21:16:22 +0800 Subject: [PATCH] fix: Tooltip containing disabled button does not show #73 --- components/button/style/index.less | 2 +- components/button/style/mixin.less | 41 ++++++++++++++++++++++-------- components/tooltip/Tooltip.jsx | 4 ++- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/components/button/style/index.less b/components/button/style/index.less index 9fcbb823e..132538c53 100644 --- a/components/button/style/index.less +++ b/components/button/style/index.less @@ -4,7 +4,7 @@ @btn-prefix-cls: ~"@{ant-prefix}-btn"; -// for compatibile +// for compatible @btn-ghost-color: @text-color; @btn-ghost-bg: transparent; @btn-ghost-border: @border-color-base; diff --git a/components/button/style/mixin.less b/components/button/style/mixin.less index d1f349509..4bbf3abdc 100644 --- a/components/button/style/mixin.less +++ b/components/button/style/mixin.less @@ -109,7 +109,8 @@ .button-group-base(@btnClassName) { position: relative; display: inline-block; - > .@{btnClassName} { + > .@{btnClassName}, + > span > .@{btnClassName} { position: relative; line-height: @btn-height-base - 2px; @@ -126,13 +127,15 @@ } // size - &-lg > .@{btnClassName} { - .button-size(@btn-height-lg; @btn-padding-lg; @btn-font-size-lg; @btn-border-radius-base); + &-lg > .@{btnClassName}, + &-lg > span > .@{btnClassName} { + .button-size(@btn-height-lg; @btn-padding-lg; @btn-font-size-lg; 0); line-height: @btn-height-lg - 2px; } - &-sm > .@{btnClassName} { - .button-size(@btn-height-sm; @btn-padding-sm; @font-size-base; @btn-border-radius-sm); + &-sm > .@{btnClassName}, + &-sm > span > .@{btnClassName} { + .button-size(@btn-height-sm; @btn-padding-sm; @font-size-base; 0); line-height: @btn-height-sm - 2px; > .@{iconfont-css-prefix} { font-size: @font-size-base; @@ -250,12 +253,17 @@ .@{btnClassName} + &, span + .@{btnClassName}, .@{btnClassName} + span, + > span + span, & + .@{btnClassName}, & + & { margin-left: -1px; } - .@{btnClassName}:not(:first-child):not(:last-child) { + .@{btnClassName}-primary + .@{btnClassName}:not(.@{btnClassName}-primary):not([disabled]) { + border-left-color: transparent; + } + + .@{btnClassName} { border-radius: 0; } @@ -266,14 +274,27 @@ > .@{btnClassName}:first-child:not(:last-child), > span:first-child:not(:last-child) > .@{btnClassName} { - border-bottom-right-radius: 0; - border-top-right-radius: 0; + border-bottom-left-radius: @btn-border-radius-base; + border-top-left-radius: @btn-border-radius-base; } > .@{btnClassName}:last-child:not(:first-child), > span:last-child:not(:first-child) > .@{btnClassName} { - border-bottom-left-radius: 0; - border-top-left-radius: 0; + border-bottom-right-radius: @btn-border-radius-base; + border-top-right-radius: @btn-border-radius-base; + } + + &-sm { + > .@{btnClassName}:first-child:not(:last-child), + > span:first-child:not(:last-child) > .@{btnClassName} { + border-bottom-left-radius: @btn-border-radius-sm; + border-top-left-radius: @btn-border-radius-sm; + } + > .@{btnClassName}:last-child:not(:first-child), + > span:last-child:not(:first-child) > .@{btnClassName} { + border-bottom-right-radius: @btn-border-radius-sm; + border-top-right-radius: @btn-border-radius-sm; + } } & > & { diff --git a/components/tooltip/Tooltip.jsx b/components/tooltip/Tooltip.jsx index e22d334ad..e1e19eb28 100644 --- a/components/tooltip/Tooltip.jsx +++ b/components/tooltip/Tooltip.jsx @@ -77,7 +77,9 @@ export default { // https://github.com/react-component/tooltip/issues/18 getDisabledCompatibleChildren (ele) { const isAntBtn = ele.componentOptions && ele.componentOptions.Ctor.options.__ANT_BUTTON - if (((isAntBtn && ele.componentOptions.propsData.disabled) || (ele.tag === 'button' && ele.data && ele.data.attrs.disabled !== false)) && this.isHoverTrigger()) { + if (((isAntBtn && (ele.componentOptions.propsData.disabled || ele.componentOptions.propsData.disabled === '')) || + (ele.tag === 'button' && ele.data && ele.data.attrs.disabled !== false)) && + this.isHoverTrigger()) { // Pick some layout related style properties up to span // Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254 const { picked, omited } = splitObject(