From 0daecf4a77ce289eb03d39aebac7d43c7076f050 Mon Sep 17 00:00:00 2001 From: Jeffrey Holland <124393578+jholland-livefront@users.noreply.github.com> Date: Mon, 6 Oct 2025 09:50:49 +0200 Subject: [PATCH] Display inline autofill on Gap.com password field (#16085) --- .../collect-autofill-content.service.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/browser/src/autofill/services/collect-autofill-content.service.ts b/apps/browser/src/autofill/services/collect-autofill-content.service.ts index 2ddee28904..47b1c9ea6d 100644 --- a/apps/browser/src/autofill/services/collect-autofill-content.service.ts +++ b/apps/browser/src/autofill/services/collect-autofill-content.service.ts @@ -433,7 +433,6 @@ export class CollectAutofillContentService implements CollectAutofillContentServ /** * Caches the autofill field element and its data. - * Will not cache the element if the index is less than 0. * * @param index - The index of the autofill field element * @param element - The autofill field element to cache @@ -444,10 +443,7 @@ export class CollectAutofillContentService implements CollectAutofillContentServ element: ElementWithOpId, autofillFieldData: AutofillField, ) { - if (index < 0) { - return; - } - + // Always cache the element, even if index is -1 (for dynamically added fields) this.autofillFieldElements.set(element, autofillFieldData); } @@ -1196,7 +1192,7 @@ export class CollectAutofillContentService implements CollectAutofillContentServ private setupOverlayListenersOnMutatedElements(mutatedElements: Node[]) { for (let elementIndex = 0; elementIndex < mutatedElements.length; elementIndex++) { const node = mutatedElements[elementIndex]; - const buildAutofillFieldItem = () => { + const buildAutofillFieldItem = async () => { if ( !this.isNodeFormFieldElement(node) || this.autofillFieldElements.get(node as ElementWithOpId) @@ -1206,7 +1202,17 @@ export class CollectAutofillContentService implements CollectAutofillContentServ // We are setting this item to a -1 index because we do not know its position in the DOM. // This value should be updated with the next call to collect page details. - void this.buildAutofillFieldItem(node as ElementWithOpId, -1); + const formFieldElement = node as ElementWithOpId; + const autofillField = await this.buildAutofillFieldItem(formFieldElement, -1); + + // Set up overlay listeners for the new field if we have the overlay service + if (autofillField && this.autofillOverlayContentService) { + this.setupOverlayOnField(formFieldElement, autofillField); + + if (this.domRecentlyMutated) { + this.updateAutofillElementsAfterMutation(); + } + } }; requestIdleCallbackPolyfill(buildAutofillFieldItem, { timeout: 1000 });