diff --git a/apps/browser/src/autofill/content/autofill-init.spec.ts b/apps/browser/src/autofill/content/autofill-init.spec.ts index 6df35c1af7..bc57d6014f 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 985ccf75ed..f98aca06b0 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); } /**