diff --git a/src/components/tooltip/Tooltip.js b/src/components/tooltip/Tooltip.js index 606d72454..d9eb02b9d 100644 --- a/src/components/tooltip/Tooltip.js +++ b/src/components/tooltip/Tooltip.js @@ -25,8 +25,6 @@ function unbindEvents(el) { el.removeEventListener('mouseleave', onMouseLeave); el.removeEventListener('click', onClick); } - - //this.unbindDocumentResizeListener(); } function onMouseEnter(event) { @@ -58,6 +56,11 @@ function show(el) { align(el); DomHandler.fadeIn(tooltipElement, 250); tooltipElement.style.zIndex = ++DomHandler.zindex; + + window.addEventListener('resize', function onWindowResize() { + hide(el); + this.removeEventListener('resize', onWindowResize); + }); } function hide(el) { @@ -92,11 +95,13 @@ function create(el) { } function remove(el) { - let tooltipElement = getTooltipElement(el); - if (tooltipElement && tooltipElement.parentElement) { - document.body.removeChild(tooltipElement); + if (el) { + let tooltipElement = getTooltipElement(el); + if (tooltipElement && tooltipElement.parentElement) { + document.body.removeChild(tooltipElement); + } + el.$_ptooltipId = null; } - el.$_ptooltipId = null; } function align(el) { diff --git a/src/views/tooltip/TooltipDoc.vue b/src/views/tooltip/TooltipDoc.vue index f29263d2e..8aa937368 100644 --- a/src/views/tooltip/TooltipDoc.vue +++ b/src/views/tooltip/TooltipDoc.vue @@ -3,15 +3,15 @@

Getting Started

-

Tooltip is a directive that needs to be imported and configured with a name of your choice.

- +

Tooltip is a directive that needs to be imported and configured with a name of your choice. Global configuration is done with the Vue.directive function.

+ import Tooltip from 'primevue/tooltip'; Vue.directive('tooltip', Tooltip);

Tooltip can also be configured locally using the directives property of your component.

- + directives: { tooltip: Tooltip }