Fix onVisibleChange, close #2134

This commit is contained in:
afc163 2016-06-22 14:09:29 +08:00
parent 2be285d236
commit b5b9175e1e
2 changed files with 4 additions and 2 deletions

View File

@ -9,7 +9,7 @@ title: 基本
import { Tooltip } from 'antd';
ReactDOM.render(
<Tooltip title="提示文字">
<Tooltip title="提示文字" onVisibleChange={visible => console.log(visible)}>
<span>鼠标移上来就会出现提示</span>
</Tooltip>
, mountNode);

View File

@ -13,6 +13,7 @@ export default class Tooltip extends React.Component {
transitionName: 'zoom-big',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
onVisibleChange() {},
}
constructor(props) {
@ -24,6 +25,7 @@ export default class Tooltip extends React.Component {
onVisibleChange = (visible) => {
this.setState({ visible });
this.props.onVisibleChange(visible);
}
getPopupDomNode() {
@ -76,6 +78,7 @@ export default class Tooltip extends React.Component {
? `${children.props.className} ${openClassName}` : openClassName;
return (
<RcTooltip
{...this.props}
transitionName={transitionName}
builtinPlacements={placements}
overlay={title}
@ -83,7 +86,6 @@ export default class Tooltip extends React.Component {
onVisibleChange={this.onVisibleChange}
onPopupAlign={this.onPopupAlign}
ref="tooltip"
{...this.props}
>
{visible ? cloneElement(children, { className: childrenCls }) : children}
</RcTooltip>