From d85a5ce10084886710d8219ca1b7ca7823f9e474 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Mon, 10 Nov 2025 15:00:53 -0600 Subject: [PATCH] Move macOS-specific position quirk to native code --- .../CredentialProviderViewController.swift | 9 +++++++-- .../services/desktop-autofill.service.ts | 16 +++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift index 3de9468c8ab..ec4f1dcb543 100644 --- a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift +++ b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift @@ -190,19 +190,24 @@ class CredentialProviderViewController: ASCredentialProviderViewController { logger.log("[autofill-extension] position: Final window frame: \(NSStringFromRect(finalWindowFrame))") // Use stabilized window frame if available, otherwise fallback to mouse position + let x, y: Int32 if finalWindowFrame.origin.x != 0 || finalWindowFrame.origin.y != 0 { let centerX = Int32(round(finalWindowFrame.origin.x)) let 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) + 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) + x = mouseX + y = mouseY } + // Add 100 pixels to the x-coordinate to offset the native OS dialog positioning. + return Position(x: x + 100, y: y) } 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 3b7bbf7779a..34ad15dec13 100644 --- a/apps/desktop/src/autofill/services/desktop-autofill.service.ts +++ b/apps/desktop/src/autofill/services/desktop-autofill.service.ts @@ -213,7 +213,7 @@ export class DesktopAutofillService implements OnDestroy { try { const response = await this.fido2AuthenticatorService.makeCredential( this.convertRegistrationRequest(request), - { windowXy: normalizePosition(request.windowXy) }, + { windowXy: request.windowXy }, controller, ); @@ -281,7 +281,7 @@ export class DesktopAutofillService implements OnDestroy { const response = await this.fido2AuthenticatorService.getAssertion( this.convertAssertionRequest(request, true), - { windowXy: normalizePosition(request.windowXy) }, + { windowXy: request.windowXy }, controller, ); @@ -309,7 +309,7 @@ export class DesktopAutofillService implements OnDestroy { try { const response = await this.fido2AuthenticatorService.getAssertion( this.convertAssertionRequest(request), - { windowXy: normalizePosition(request.windowXy) }, + { windowXy: request.windowXy }, controller, ); @@ -442,14 +442,4 @@ export class DesktopAutofillService implements OnDestroy { this.destroy$.next(); 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 xPostionOffset = 100; - - return { - x: Math.round(position.x + xPostionOffset), - y: Math.round(position.y), - }; } \ No newline at end of file