[PM-8833] Fixing an issue with SPA support

This commit is contained in:
Cesar Gonzalez 2024-10-03 13:03:55 -05:00
parent dc03c66f15
commit 90448c86f8
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
4 changed files with 18 additions and 5 deletions

View File

@ -73,6 +73,10 @@ class LegacyAutofillOverlayContentService implements LegacyAutofillOverlayConten
* Satisfy the AutofillOverlayContentService interface.
*/
messageHandlers = {} as AutofillOverlayContentExtensionMessageHandlers;
clearUserFilledFields() {
// do nothing
}
async setupOverlayListeners(
autofillFieldElement: ElementWithOpId<FormFieldElement>,
autofillFieldData: AutofillField,

View File

@ -45,5 +45,6 @@ export interface AutofillOverlayContentService {
pageDetails: AutofillPageDetails,
): Promise<void>;
blurMostRecentlyFocusedField(isClosingInlineMenu?: boolean): void;
clearUserFilledFields(): void;
destroy(): void;
}

View File

@ -216,6 +216,17 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
}
}
/**
* Clears all cached user filled fields.
*/
clearUserFilledFields() {
Object.keys(this.userFilledFields).forEach((key) => {
if (this.userFilledFields[key]) {
delete this.userFilledFields[key];
}
});
}
/**
* Formats any found user filled fields for a login cipher and sends a message
* to the background script to add a new cipher.
@ -1662,11 +1673,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
formFieldElement.removeEventListener(EVENTS.KEYUP, this.handleFormFieldKeyupEvent);
this.formFieldElements.delete(formFieldElement);
});
Object.keys(this.userFilledFields).forEach((key) => {
if (this.userFilledFields[key]) {
delete this.userFilledFields[key];
}
});
this.clearUserFilledFields();
this.userFilledFields = null;
globalThis.removeEventListener(EVENTS.MESSAGE, this.handleWindowMessageEvent);
globalThis.document.removeEventListener(

View File

@ -961,6 +961,7 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
this.domRecentlyMutated = true;
if (this.autofillOverlayContentService) {
this.autofillOverlayContentService.pageDetailsUpdateRequired = true;
this.autofillOverlayContentService.clearUserFilledFields();
void this.sendExtensionMessage("closeAutofillInlineMenu", { forceCloseInlineMenu: true });
}
this.noFieldsFound = false;