Add rule for don't show tooltip when dropdown is open. Closes #5194

This commit is contained in:
Tainan Felipe Pauli de Almeida 2018-03-29 10:40:50 -03:00
parent b618f7035b
commit bef61eeeda

View File

@ -18,6 +18,14 @@ const defaultProps = {
}; };
class Tooltip extends Component { class Tooltip extends Component {
static wait(show, event) {
const tooltipTarget = event.target;
const expandedEl = tooltipTarget.parentElement.querySelector('[aria-expanded="true"]');
const isTarget = expandedEl === tooltipTarget;
if (expandedEl && !isTarget) return;
show();
}
constructor(props) { constructor(props) {
super(props); super(props);
@ -40,12 +48,11 @@ class Tooltip extends Component {
delay: this.delay, delay: this.delay,
onShow: this.onShow, onShow: this.onShow,
onHide: this.onHide, onHide: this.onHide,
wait: Tooltip.wait,
touchHold: true, touchHold: true,
}; };
this.tooltip = Tippy(`#${this.tippySelectorId}`, options); this.tooltip = Tippy(`#${this.tippySelectorId}`, options);
} }
onShow() { onShow() {
document.addEventListener('keyup', this.handleEscapeHide); document.addEventListener('keyup', this.handleEscapeHide);
} }
@ -56,7 +63,6 @@ class Tooltip extends Component {
handleEscapeHide(e) { handleEscapeHide(e) {
if (e.keyCode !== ESCAPE) return; if (e.keyCode !== ESCAPE) return;
this.tooltip.tooltips[0].hide(); this.tooltip.tooltips[0].hide();
} }