mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Fix Username Icon position on Apple login page (#1590)
Fix Username Icon position on Apple login page
This commit is contained in:
parent
b67f05328c
commit
adeb6add9a
2 changed files with 23 additions and 1 deletions
|
|
@ -175,3 +175,18 @@ kpxcSites.popupExceptionFound = function(combinations) {
|
|||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles a few exceptions for certain sites where Username Icon is not placed properly.
|
||||
* @param {number} left Absolute left position of the icon
|
||||
* @param {number} top Absolute top position of the icon
|
||||
* @param {number} iconSize Size of the icon
|
||||
* @returns {array} New left and top values as an Array
|
||||
*/
|
||||
kpxcSites.iconOffset = function(left, top, iconSize) {
|
||||
if (document.location.hostname.includes('idmsa.apple.com')) {
|
||||
return [ left - (iconSize + 10), top + 3 ];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -123,13 +123,20 @@ kpxcUI.setIconPosition = function(icon, field, rtl = false, segmented = false) {
|
|||
const size = Number(icon.getAttribute('size'));
|
||||
const offset = kpxcUI.calculateIconOffset(field, size);
|
||||
let left = kpxcUI.bodyStyle.position.toLowerCase() === 'relative' ? rect.left - kpxcUI.bodyRect.left : rect.left;
|
||||
const top = kpxcUI.bodyStyle.position.toLowerCase() === 'relative' ? rect.top - kpxcUI.bodyRect.top : rect.top;
|
||||
let top = kpxcUI.bodyStyle.position.toLowerCase() === 'relative' ? rect.top - kpxcUI.bodyRect.top : rect.top;
|
||||
|
||||
// Add more space for the icon to show it at the right side of the field if TOTP fields are segmented
|
||||
if (segmented) {
|
||||
left += size + 10;
|
||||
}
|
||||
|
||||
// Adjusts the icon offset for certain sites
|
||||
const iconOffset = kpxcSites.iconOffset(left, top, size);
|
||||
if (iconOffset) {
|
||||
left = iconOffset[0];
|
||||
top = iconOffset[1];
|
||||
}
|
||||
|
||||
const scrollTop = document.scrollingElement ? document.scrollingElement.scrollTop : 0;
|
||||
const scrollLeft = document.scrollingElement ? document.scrollingElement.scrollLeft : 0;
|
||||
icon.style.top = Pixels(top + scrollTop + offset + 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue