mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
just hide toottip overlay when there is no title
avoid rerender children when title is changed
This commit is contained in:
parent
11b47aa79b
commit
9b5311791e
@ -10,6 +10,14 @@ export default React.createClass({
|
||||
mouseLeaveDelay: 0.1
|
||||
};
|
||||
},
|
||||
getInitialState() {
|
||||
return {
|
||||
visible: false
|
||||
};
|
||||
},
|
||||
onVisibleChange(visible) {
|
||||
this.setState({ visible });
|
||||
},
|
||||
render() {
|
||||
let transitionName = ({
|
||||
top: 'zoom-down',
|
||||
@ -17,12 +25,21 @@ export default React.createClass({
|
||||
left: 'zoom-right',
|
||||
right: 'zoom-left'
|
||||
})[this.props.placement];
|
||||
|
||||
// Hide tooltip when there is no title
|
||||
let visible = this.state.visible;
|
||||
if (!this.props.title) {
|
||||
visible = false;
|
||||
}
|
||||
|
||||
return (
|
||||
this.props.title ? <Tooltip transitionName={transitionName}
|
||||
<Tooltip transitionName={transitionName}
|
||||
overlay={this.props.title}
|
||||
visible={visible}
|
||||
onVisibleChange={this.onVisibleChange}
|
||||
{...this.props}>
|
||||
{this.props.children}
|
||||
</Tooltip> : this.props.children
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -52,6 +52,7 @@
|
||||
background-color: @tooltip-bg;
|
||||
border-radius: @border-radius-base;
|
||||
box-shadow: @overlay-shadow;
|
||||
min-height: 34px;
|
||||
}
|
||||
|
||||
// Arrows
|
||||
|
Loading…
Reference in New Issue
Block a user