1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

[EC-598] feat: center popup

This commit is contained in:
Andreas Coroiu
2022-12-16 09:26:57 +01:00
parent 2259519724
commit f6b58d812d
2 changed files with 14 additions and 4 deletions

View File

@@ -42,7 +42,7 @@ export class PopupUtilsService {
}
}
popOut(win: Window, href: string = null): void {
popOut(win: Window, href: string = null, options: { center?: boolean } = {}): void {
if (href === null) {
href = win.location.href;
}
@@ -60,11 +60,17 @@ export class PopupUtilsService {
}
const bodyRect = document.querySelector("body").getBoundingClientRect();
const width = Math.round(bodyRect.width ? bodyRect.width + 60 : 375);
const height = Math.round(bodyRect.height || 600);
const top = options.center ? Math.round((screen.height - height) / 2) : undefined;
const left = options.center ? Math.round((screen.width - width) / 2) : undefined;
chrome.windows.create({
url: href,
type: "popup",
width: Math.round(bodyRect.width ? bodyRect.width + 60 : 375),
height: Math.round(bodyRect.height || 600),
width,
height,
top,
left,
});
if (win && this.inPopup(win)) {

View File

@@ -44,7 +44,11 @@ export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServi
const requestId = Utils.newGuid();
const data: BrowserFido2Message = { type: "VerifyUserRequest", requestId };
const queryParams = new URLSearchParams(data).toString();
this.popupUtilsService.popOut(null, `popup/index.html?uilocation=popout#/fido2?${queryParams}`);
this.popupUtilsService.popOut(
null,
`popup/index.html?uilocation=popout#/fido2?${queryParams}`,
{ center: true }
);
const response = await lastValueFrom(
this.messages$.pipe(