Fixed #523 - Tooltip doesn't close in scrollable containers

pull/525/head
mertsincan 2020-10-02 13:23:19 +03:00
parent 50c312d0e9
commit 5c08797500
1 changed files with 26 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import UniqueComponentId from '../utils/UniqueComponentId';
import DomHandler from '../utils/DomHandler';
import ConnectedOverlayScrollHandler from '../utils/ConnectedOverlayScrollHandler';
function bindEvents(el) {
const modifiers = el.$_ptooltipModifiers;
@ -27,6 +28,22 @@ function unbindEvents(el) {
}
}
function bindScrollListener(el) {
if (!el.$_ptooltipScrollHandler) {
el.$_ptooltipScrollHandler = new ConnectedOverlayScrollHandler(el, function() {
hide(el);
});
}
el.$_ptooltipScrollHandler.bindScrollListener();
}
function unbindScrollListener(el) {
if (el.$_ptooltipScrollHandler) {
el.$_ptooltipScrollHandler.unbindScrollListener();
}
}
function onMouseEnter(event) {
show(event.currentTarget);
}
@ -61,10 +78,13 @@ function show(el) {
hide(el);
this.removeEventListener('resize', onWindowResize);
});
bindScrollListener(el);
}
function hide(el) {
remove(el);
unbindScrollListener(el);
}
function getTooltipElement(el) {
@ -225,6 +245,11 @@ const Tooltip = {
unmounted(el) {
remove(el);
unbindEvents(el);
if (el.$_ptooltipScrollHandler) {
el.$_ptooltipScrollHandler.destroy();
el.$_ptooltipScrollHandler = null;
}
},
updated(el, options) {
el.$_ptooltipModifiers = options.modifiers;