From 7f419936489a8e60c0f9a7f3ec946c829cdd856b Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 28 May 2021 15:28:04 +0200 Subject: [PATCH] prevent buttons with negative margin to displace message menu --- src/platform/web/ui/general/Popup.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/platform/web/ui/general/Popup.js b/src/platform/web/ui/general/Popup.js index b5df3a23..ac5e3160 100644 --- a/src/platform/web/ui/general/Popup.js +++ b/src/platform/web/ui/general/Popup.js @@ -104,9 +104,10 @@ export class Popup { _onScroll() { if (this._scroller && !this._isVisibleInScrollParent(VerticalAxis)) { this.close(); + } else { + this._applyArrangementAxis(HorizontalAxis, this._arrangement.horizontal); + this._applyArrangementAxis(VerticalAxis, this._arrangement.vertical); } - this._applyArrangementAxis(HorizontalAxis, this._arrangement.horizontal); - this._applyArrangementAxis(VerticalAxis, this._arrangement.vertical); } _onClick() { @@ -190,7 +191,15 @@ function findScrollParent(el) { do { parent = parent.parentElement; if (parent.scrollHeight > parent.clientHeight) { - return parent; + // double check that overflow would allow a scrollbar + // because some elements, like a button with negative margin to increate the click target + // can cause the scrollHeight to be larger than the clientHeight in the parent + // see button.link class + const style = window.getComputedStyle(parent); + const {overflow} = style; + if (overflow === "auto" || overflow === "scroll") { + return parent; + } } } while (parent !== el.offsetParent); }