|
|
|
|
@ -12,7 +12,7 @@ export const popover = { |
|
|
|
|
open({ currentTarget, ...config }) { |
|
|
|
|
// Popover position must be computed as soon as possible, avoiding DOM changes over currentTarget
|
|
|
|
|
const data = { |
|
|
|
|
targetRect: currentTarget && currentTarget.getBoundingClientRect && currentTarget.getBoundingClientRect(), |
|
|
|
|
targetRect: currentTarget?.getBoundingClientRect(), |
|
|
|
|
...config, |
|
|
|
|
}; |
|
|
|
|
this.renderedPopover = Blaze.renderWithData(Template.popover, data, document.body); |
|
|
|
|
@ -131,9 +131,14 @@ Template.popover.onRendered(function() { |
|
|
|
|
} |
|
|
|
|
popoverContent.style.opacity = 1; |
|
|
|
|
}, 50); |
|
|
|
|
|
|
|
|
|
const observer = new MutationObserver(position); |
|
|
|
|
observer.observe(popoverContent, { childList: true, subtree: true }); |
|
|
|
|
|
|
|
|
|
$(window).on('resize', position); |
|
|
|
|
position(); |
|
|
|
|
this.position = position; |
|
|
|
|
this.observer = observer; |
|
|
|
|
|
|
|
|
|
this.firstNode.style.visibility = 'visible'; |
|
|
|
|
}); |
|
|
|
|
@ -143,6 +148,7 @@ Template.popover.onDestroyed(function() { |
|
|
|
|
this.data.onDestroyed(); |
|
|
|
|
} |
|
|
|
|
$(window).off('resize', this.position); |
|
|
|
|
this.observer?.disconnect(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Template.popover.events({ |
|
|
|
|
|