prevent buttons with negative margin to displace message menu

This commit is contained in:
Bruno Windels 2021-05-28 15:28:04 +02:00
parent b3749f2d92
commit 7f41993648

View file

@ -104,10 +104,11 @@ export class Popup {
_onScroll() { _onScroll() {
if (this._scroller && !this._isVisibleInScrollParent(VerticalAxis)) { if (this._scroller && !this._isVisibleInScrollParent(VerticalAxis)) {
this.close(); this.close();
} } else {
this._applyArrangementAxis(HorizontalAxis, this._arrangement.horizontal); this._applyArrangementAxis(HorizontalAxis, this._arrangement.horizontal);
this._applyArrangementAxis(VerticalAxis, this._arrangement.vertical); this._applyArrangementAxis(VerticalAxis, this._arrangement.vertical);
} }
}
_onClick() { _onClick() {
this.close(); this.close();
@ -190,7 +191,15 @@ function findScrollParent(el) {
do { do {
parent = parent.parentElement; parent = parent.parentElement;
if (parent.scrollHeight > parent.clientHeight) { if (parent.scrollHeight > parent.clientHeight) {
// 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; return parent;
} }
}
} while (parent !== el.offsetParent); } while (parent !== el.offsetParent);
} }