1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

Display inline autofill on Gap.com password field (#16085)

This commit is contained in:
Jeffrey Holland
2025-10-06 09:50:49 +02:00
committed by GitHub
parent 96841129e6
commit 0daecf4a77

View File

@@ -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<FormFieldElement>,
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<FormFieldElement>)
@@ -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<FormFieldElement>, -1);
const formFieldElement = node as ElementWithOpId<FormFieldElement>;
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 });