diff --git a/front/core/components/popover/popover.js b/front/core/components/popover/popover.js index ea864ca88..804d0383b 100644 --- a/front/core/components/popover/popover.js +++ b/front/core/components/popover/popover.js @@ -118,6 +118,7 @@ export default class Popover extends Component { */ relocate() { if (!(this.parent && this._shown)) return; + let margin = 10; let style = this.popover.style; style.width = ''; @@ -136,9 +137,8 @@ export default class Popover extends Component { let height = popoverRect.height; let width = Math.max(popoverRect.width, parentRect.width); let top = parentRect.top + parentRect.height + arrowHeight; - let left = parentRect.left + parentRect.width / 2 - width / 2; + let left = Math.max(parentRect.left + parentRect.width / 2 - width / 2, margin); - let margin = 10; let showTop = top + height + margin > window.innerHeight; if (showTop) @@ -151,7 +151,10 @@ export default class Popover extends Component { else arrowStyle.top = `0`; - arrowStyle.left = `${(parentRect.left - left) + parentRect.width / 2}px`; + let arrowMargin = margin + 10; + let arrowLeft = (parentRect.left - left) + parentRect.width / 2; + arrowLeft = Math.max(Math.min(arrowLeft, width - arrowMargin), arrowMargin); + arrowStyle.left = `${arrowLeft}px`; style.top = `${top}px`; style.left = `${left}px`;