Use defaultView instead of scrollingElement when positioning icons and menus (#1873)

Use defaultView instead of scrollingElement when positioning icons and menus
This commit is contained in:
Sami Vänttinen 2023-03-12 09:53:02 +02:00 committed by GitHub
parent 7bb0f83271
commit dd9d316f13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 9 deletions

View file

@ -283,12 +283,14 @@ class Autocomplete {
this.container.classList.remove('kpxcAutocomplete-container-on-top');
}
const scrollTop = kpxcUI.getScrollTop();
const scrollLeft = kpxcUI.getScrollLeft();
if (kpxcUI.bodyStyle.position.toLowerCase() === 'relative') {
this.container.style.top = Pixels(rect.top - kpxcUI.bodyRect.top + document.scrollingElement.scrollTop + this.input.offsetHeight - menuOffset);
this.container.style.left = Pixels(rect.left - kpxcUI.bodyRect.left + document.scrollingElement.scrollLeft);
this.container.style.top = Pixels(rect.top - kpxcUI.bodyRect.top + scrollTop + this.input.offsetHeight - menuOffset);
this.container.style.left = Pixels(rect.left - kpxcUI.bodyRect.left + scrollLeft);
} else {
this.container.style.top = Pixels(rect.top + document.scrollingElement.scrollTop + this.input.offsetHeight - menuOffset);
this.container.style.left = Pixels(rect.left + document.scrollingElement.scrollLeft);
this.container.style.top = Pixels(rect.top + scrollTop + this.input.offsetHeight - menuOffset);
this.container.style.left = Pixels(rect.left + scrollLeft);
}
}
}

View file

@ -621,8 +621,8 @@ kpxcCustomLoginFieldsBanner.setSelectionPosition = function(field) {
const rect = field.originalElement.getBoundingClientRect();
const left = kpxcUI.getRelativeLeftPosition(rect);
const top = kpxcUI.getRelativeTopPosition(rect);
const scrollTop = document.scrollingElement ? document.scrollingElement.scrollTop : 0;
const scrollLeft = document.scrollingElement ? document.scrollingElement.scrollLeft : 0;
const scrollTop = kpxcUI.getScrollTop();
const scrollLeft = kpxcUI.getScrollLeft();
field.style.top = Pixels(top + scrollTop);
field.style.left = Pixels(left + scrollLeft);

View file

@ -143,14 +143,22 @@ kpxcUI.setIconPosition = function(icon, field, rtl = false, segmented = false) {
top = iconOffset[1];
}
const scrollTop = document.scrollingElement ? document.scrollingElement.scrollTop : 0;
const scrollLeft = document.scrollingElement ? document.scrollingElement.scrollLeft : 0;
const scrollTop = kpxcUI.getScrollTop();
const scrollLeft = kpxcUI.getScrollLeft();
icon.style.top = Pixels(top + scrollTop + offset + 1);
icon.style.left = rtl
? Pixels((left + scrollLeft) + offset)
: Pixels(left + scrollLeft + field.offsetWidth - size - offset);
};
kpxcUI.getScrollTop = function() {
return document.defaultView?.scrollY ?? document.scrollingElement?.scrollTop ?? 0;
};
kpxcUI.getScrollLeft = function() {
return document.defaultView?.scrollX ?? document.scrollingElement?.scrollLeft ?? 0;
};
kpxcUI.getRelativeLeftPosition = function(rect) {
return kpxcUI.bodyStyle.position.toLowerCase() === 'relative' ? rect.left - kpxcUI.bodyRect.left : rect.left;
};

View file

@ -158,7 +158,7 @@
"applications": {
"gecko": {
"id": "keepassxc-browser@keepassxc.org",
"strict_min_version": "67.0"
"strict_min_version": "74.0"
}
},
"default_locale": "en"