From e894ecda25e7b9c75f6f4b8f69587ef1b95b139d Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Thu, 22 Feb 2024 12:50:21 -0600 Subject: [PATCH] [PM-6213] Fix Inline Autofill Menu Erasing Filled Form on Hilton.com (#7952) * [PM-6213] Fix Inline Autofill Menu Erasing Filled Form on Hilton.com * [PM-6213] Fixing jest test --- .../src/autofill/content/autofill-init.spec.ts | 17 +++++++++++++---- .../src/autofill/content/autofill-init.ts | 6 ++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/browser/src/autofill/content/autofill-init.spec.ts b/apps/browser/src/autofill/content/autofill-init.spec.ts index 6df35c1af7b..bc57d6014f7 100644 --- a/apps/browser/src/autofill/content/autofill-init.spec.ts +++ b/apps/browser/src/autofill/content/autofill-init.spec.ts @@ -208,7 +208,19 @@ describe("AutofillInit", () => { ); }); - it("updates the isCurrentlyFilling properties of the overlay and focus the recent field after filling", async () => { + it("removes the overlay when filling the form", async () => { + const blurAndRemoveOverlaySpy = jest.spyOn(autofillInit as any, "blurAndRemoveOverlay"); + sendExtensionRuntimeMessage({ + command: "fillForm", + fillScript, + pageDetailsUrl: window.location.href, + }); + await flushPromises(); + + expect(blurAndRemoveOverlaySpy).toHaveBeenCalled(); + }); + + it("updates the isCurrentlyFilling property of the overlay to true after filling", async () => { jest.useFakeTimers(); jest.spyOn(autofillInit as any, "updateOverlayIsCurrentlyFilling"); jest @@ -228,9 +240,6 @@ describe("AutofillInit", () => { fillScript, ); expect(autofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(2, false); - expect( - autofillInit["autofillOverlayContentService"].focusMostRecentOverlayField, - ).toHaveBeenCalled(); }); it("skips attempting to focus the most recent field if the autofillOverlayContentService is not present", async () => { diff --git a/apps/browser/src/autofill/content/autofill-init.ts b/apps/browser/src/autofill/content/autofill-init.ts index 985ccf75eda..f98aca06b01 100644 --- a/apps/browser/src/autofill/content/autofill-init.ts +++ b/apps/browser/src/autofill/content/autofill-init.ts @@ -98,6 +98,7 @@ class AutofillInit implements AutofillInitInterface { return; } + this.blurAndRemoveOverlay(); this.updateOverlayIsCurrentlyFilling(true); await this.insertAutofillContentService.fillForm(fillScript); @@ -105,10 +106,7 @@ class AutofillInit implements AutofillInitInterface { return; } - setTimeout(() => { - this.updateOverlayIsCurrentlyFilling(false); - this.autofillOverlayContentService.focusMostRecentOverlayField(); - }, 250); + setTimeout(() => this.updateOverlayIsCurrentlyFilling(false), 250); } /**