Compare commits

...

1 Commits

Author SHA1 Message Date
Pierre Donias
67f7ce40da fix(xo-web/tooltip): tooltip disappearing when children change
- Don't remove the listeners when the children change
  (The children change but the <Tooltip /> is still there)
- Don't add new listeners when the childrent change
- Update the tooltip on mouseenter so the position is correct
  even when the tooltipped elements appears under the cursor
2019-07-23 15:59:43 +02:00

View File

@@ -81,18 +81,6 @@ export default class Tooltip extends Component {
this._removeListeners() this._removeListeners()
} }
componentWillReceiveProps(props) {
if (props.children !== this.props.children) {
this._removeListeners()
}
}
componentDidUpdate(prevProps) {
if (prevProps.children !== this.props.children) {
this._addListeners()
}
}
_addListeners() { _addListeners() {
const node = (this._node = ReactDOM.findDOMNode(this)) const node = (this._node = ReactDOM.findDOMNode(this))
@@ -116,15 +104,18 @@ export default class Tooltip extends Component {
this._node = null this._node = null
} }
_showTooltip = () => { _showTooltip = event => {
const { props } = this const { props } = this
instance.setState({ instance.setState(
className: props.className, {
content: props.content, className: props.className,
show: true, content: props.content,
style: props.style, show: true,
}) style: props.style,
},
() => this._updateTooltip(event)
)
} }
_hideTooltip = () => { _hideTooltip = () => {