diff --git a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift index 3de9468c8ab..2aa6c7fe639 100644 --- a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift +++ b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift @@ -189,20 +189,21 @@ class CredentialProviderViewController: ASCredentialProviderViewController { let finalWindowFrame = self.view.window?.frame ?? .zero logger.log("[autofill-extension] position: Final window frame: \(NSStringFromRect(finalWindowFrame))") + let centerX, centerY: Int32; // Use stabilized window frame if available, otherwise fallback to mouse position if finalWindowFrame.origin.x != 0 || finalWindowFrame.origin.y != 0 { - let centerX = Int32(round(finalWindowFrame.origin.x)) - let centerY = Int32(round(screenHeight - finalWindowFrame.origin.y)) + centerX = Int32(round(finalWindowFrame.origin.x)) + centerY = Int32(round(screenHeight - finalWindowFrame.origin.y)) logger.log("[autofill-extension] position: Using window position: x=\(centerX), y=\(centerY)") - return Position(x: centerX, y: centerY) } else { // Fallback to mouse position let mouseLocation = NSEvent.mouseLocation - let mouseX = Int32(round(mouseLocation.x)) - let mouseY = Int32(round(screenHeight - mouseLocation.y)) - logger.log("[autofill-extension] position: Using mouse position fallback: x=\(mouseX), y=\(mouseY)") - return Position(x: mouseX, y: mouseY) + centerX = Int32(round(mouseLocation.x)) + centerY = Int32(round(screenHeight - mouseLocation.y)) + logger.log("[autofill-extension] position: Using mouse position fallback: x=\(centerX), y=\(centerY)") } + // Add 100 pixels to the x-coordinate to offset the native OS dialog positioning. + return Position(x: centerX + 100, y: centerY) } override func viewDidLoad() { diff --git a/apps/desktop/src/autofill/services/desktop-autofill.service.ts b/apps/desktop/src/autofill/services/desktop-autofill.service.ts index d819b0fe35b..953ae111397 100644 --- a/apps/desktop/src/autofill/services/desktop-autofill.service.ts +++ b/apps/desktop/src/autofill/services/desktop-autofill.service.ts @@ -227,7 +227,7 @@ export class DesktopAutofillService implements OnDestroy { try { const response = await this.fido2AuthenticatorService.makeCredential( this.convertRegistrationRequest(request), - { windowXy: normalizePosition(request.windowXy) }, + { windowXy: request.windowXy }, controller, ); @@ -293,7 +293,7 @@ export class DesktopAutofillService implements OnDestroy { const response = await this.fido2AuthenticatorService.getAssertion( this.convertAssertionRequest(request, true), - { windowXy: normalizePosition(request.windowXy) }, + { windowXy: request.windowXy }, controller, ); @@ -321,7 +321,7 @@ export class DesktopAutofillService implements OnDestroy { try { const response = await this.fido2AuthenticatorService.getAssertion( this.convertAssertionRequest(request), - { windowXy: normalizePosition(request.windowXy) }, + { windowXy: request.windowXy }, controller, ); @@ -455,13 +455,3 @@ export class DesktopAutofillService implements OnDestroy { this.destroy$.complete(); } } - -function normalizePosition(position: { x: number; y: number }): { x: number; y: number } { - // Add 100 pixels to the x-coordinate to offset the native OS dialog positioning. - const xPositionOffset = 100; - - return { - x: Math.round(position.x + xPositionOffset), - y: Math.round(position.y), - }; -}