Skip to content

Commit

Permalink
fix(tooltip+popover): improve blur trigger handling
Browse files Browse the repository at this point in the history
Better handling of focus moving between tip and element
  • Loading branch information
tmorehouse committed Nov 17, 2017
1 parent d1658c1 commit c08b815
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/utils/tooltip.class.js
Expand Up @@ -644,17 +644,24 @@ class ToolTip {
this.enter(e);
} else if (type === 'focusout') {
// target is the element which is loosing focus
// And relatdTarget is the element gaining focus
if (target === $element && $tip && $tip.contains(relatedTarget)) {
// And relatedTarget is the element gaining focus
if ($tip && $element && $element.contains(target) && $tip.contains(relatedTarget)) {
// If focus moves from $element to $tip, don't trigger a leave
return;
}
if ($tip && target === $tip && $element.contains(relatedTarget)) {
if ($tip && $element && $tip.contains(target) && $element.contains(relatedTarget)) {
// If focus moves from $tip to $element, don't trigger a leave
// This will only happen during the whileOpen listeners
return;
}
// OPtherwise trigger a leave
if ($tip && $tip.contains(target) && $tip.contains(relatedTarget)) {
// If focus moves within $tip, don't trigger a leave
return;
}
if ($element && $element.contains(target) && $element.contains(relatedTarget)) {
// If focus moves within $element, don't trigger a leave
return;
}
// Otherwise trigger a leave
this.leave(e);
} else if (type === 'mouseleave') {
this.leave(e);
Expand Down

0 comments on commit c08b815

Please sign in to comment.