mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
[EC-598] feat: center popup
This commit is contained in:
@@ -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) {
|
if (href === null) {
|
||||||
href = win.location.href;
|
href = win.location.href;
|
||||||
}
|
}
|
||||||
@@ -60,11 +60,17 @@ export class PopupUtilsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bodyRect = document.querySelector("body").getBoundingClientRect();
|
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({
|
chrome.windows.create({
|
||||||
url: href,
|
url: href,
|
||||||
type: "popup",
|
type: "popup",
|
||||||
width: Math.round(bodyRect.width ? bodyRect.width + 60 : 375),
|
width,
|
||||||
height: Math.round(bodyRect.height || 600),
|
height,
|
||||||
|
top,
|
||||||
|
left,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (win && this.inPopup(win)) {
|
if (win && this.inPopup(win)) {
|
||||||
|
|||||||
@@ -44,7 +44,11 @@ export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServi
|
|||||||
const requestId = Utils.newGuid();
|
const requestId = Utils.newGuid();
|
||||||
const data: BrowserFido2Message = { type: "VerifyUserRequest", requestId };
|
const data: BrowserFido2Message = { type: "VerifyUserRequest", requestId };
|
||||||
const queryParams = new URLSearchParams(data).toString();
|
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(
|
const response = await lastValueFrom(
|
||||||
this.messages$.pipe(
|
this.messages$.pipe(
|
||||||
|
|||||||
Reference in New Issue
Block a user