diff --git a/front/core/components/popover/popover.js b/front/core/components/popover/popover.js index f6f2dcb96..10fdf3c31 100644 --- a/front/core/components/popover/popover.js +++ b/front/core/components/popover/popover.js @@ -120,7 +120,6 @@ export default class Popover extends Component { if (!(this.parent && this._shown)) return; let margin = 10; - let scrollbarSize = 10; let style = this.popover.style; style.width = ''; @@ -135,11 +134,12 @@ export default class Popover extends Component { let arrowRect = this.arrow.getBoundingClientRect(); let clamp = (value, min, max) => Math.min(Math.max(value, min), max); - let arrowHeight = Math.sqrt(Math.pow(arrowRect.height, 2) * 2) / 2; + let arrowHeight = Math.floor(arrowRect.height / 2); + let arrowOffset = arrowHeight + margin / 2; - let endMargin = margin + scrollbarSize; - let maxRight = window.innerWidth - endMargin; - let maxBottom = window.innerHeight - endMargin; + let docEl = document.documentElement; + let maxRight = Math.min(window.innerWidth, docEl.clientWidth) - margin; + let maxBottom = Math.min(window.innerHeight, docEl.clientHeight) - margin; let maxWith = maxRight - margin; let maxHeight = maxBottom - margin - arrowHeight; @@ -149,9 +149,9 @@ export default class Popover extends Component { let left = parentRect.left + parentRect.width / 2 - width / 2; left = clamp(left, margin, maxRight - width); - let top = parentRect.top + parentRect.height + arrowHeight; + let top = parentRect.top + parentRect.height + arrowOffset; let showTop = top + height > maxBottom; - if (showTop) top = parentRect.top - height - arrowHeight; + if (showTop) top = parentRect.top - height - arrowOffset; top = Math.max(top, margin); if (showTop)