diff --git a/src/components/utils/DomHandler.js b/src/components/utils/DomHandler.js index 354eef3917..3f499cd245 100644 --- a/src/components/utils/DomHandler.js +++ b/src/components/utils/DomHandler.js @@ -187,13 +187,18 @@ export default class DomHandler { let viewport = this.getViewport(); let top, left; - if (targetOffset.top + targetOuterHeight + elementOuterHeight > viewport.height) + if (targetOffset.top + targetOuterHeight + elementOuterHeight > viewport.height) { top = targetOffset.top + windowScrollTop - elementOuterHeight; - else + if(top < 0) { + top = 0 + windowScrollTop; + } + } + else { top = targetOuterHeight + targetOffset.top + windowScrollTop; + } if (targetOffset.left + targetOuterWidth + elementOuterWidth > viewport.width) - left = targetOffset.left + windowScrollLeft + targetOuterWidth - elementOuterWidth; + left = Math.max(0, targetOffset.left + windowScrollLeft + targetOuterWidth - elementOuterWidth); else left = targetOffset.left + windowScrollLeft;