mirror of
https://github.com/bitwarden/browser
synced 2026-02-05 19:23:19 +00:00
Autofill/pm 21864 center unlock vault modal (#14867)
* Center the Locked Vault modal when using passkeys * Revert swift changes and handle offscreen modals * Remove comments
This commit is contained in:
@@ -138,14 +138,13 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
|
||||
|
||||
private func getWindowPosition() -> Position {
|
||||
let frame = self.view.window?.frame ?? .zero
|
||||
let screenHeight = NSScreen.main?.frame.height ?? 0
|
||||
|
||||
let screenHeight = NSScreen.main?.frame.height ?? 0
|
||||
|
||||
// frame.width and frame.height is always 0. Estimating works OK for now.
|
||||
let estimatedWidth:CGFloat = 400;
|
||||
let estimatedHeight:CGFloat = 200;
|
||||
let centerX = Int32(round(frame.origin.x + estimatedWidth/2))
|
||||
let centerY = Int32(round(screenHeight - (frame.origin.y + estimatedHeight/2)))
|
||||
|
||||
return Position(x: centerX, y:centerY)
|
||||
}
|
||||
|
||||
|
||||
@@ -265,6 +265,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
||||
): Promise<void> {
|
||||
// Load the UI:
|
||||
await this.desktopSettingsService.setModalMode(true, showTrafficButtons, position);
|
||||
await this.centerOffscreenPopup();
|
||||
await this.router.navigate([
|
||||
route,
|
||||
{
|
||||
@@ -341,7 +342,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
||||
|
||||
const status = await firstValueFrom(this.authService.activeAccountStatus$);
|
||||
if (status !== AuthenticationStatus.Unlocked) {
|
||||
await this.showUi("/lock", this.windowObject.windowXy, true, true);
|
||||
await this.showUi("/lock", undefined, true, true);
|
||||
|
||||
let status2: AuthenticationStatus;
|
||||
try {
|
||||
@@ -370,4 +371,25 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
||||
async close() {
|
||||
this.logService.warning("close");
|
||||
}
|
||||
|
||||
private async centerOffscreenPopup() {
|
||||
if (!this.windowObject.windowXy) {
|
||||
return;
|
||||
}
|
||||
|
||||
const popupWidth = 600;
|
||||
const popupHeight = 600;
|
||||
|
||||
const window = await firstValueFrom(this.desktopSettingsService.window$);
|
||||
const { width, height } = window.displayBounds;
|
||||
const { x, y } = this.windowObject.windowXy;
|
||||
|
||||
if (x < popupWidth || x > width - popupWidth || y < popupHeight || y > height - popupHeight) {
|
||||
const popupHeightOffset = 300;
|
||||
const { width, height } = window.displayBounds;
|
||||
const centeredX = width / 2;
|
||||
const centeredY = (height - popupHeightOffset) / 2;
|
||||
this.windowObject.windowXy = { x: centeredX, y: centeredY };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user