diff --git a/apps/browser/src/autofill/services/autofill-constants.ts b/apps/browser/src/autofill/services/autofill-constants.ts index 42885ab8f9..19124fb84f 100644 --- a/apps/browser/src/autofill/services/autofill-constants.ts +++ b/apps/browser/src/autofill/services/autofill-constants.ts @@ -870,14 +870,7 @@ export class IdentityAutoFillConstants { }; } -export const SubmitLoginButtonNames: string[] = [ - "login", - "signin", - "submit", - "continue", - "next", - "go", -]; +export const SubmitLoginButtonNames: string[] = ["login", "signin", "submit", "continue", "next"]; export const SubmitChangePasswordButtonNames: string[] = [ "change", diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts index 9e6e29e8fd..fe3b29a15a 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts @@ -34,6 +34,7 @@ import { elementIsFillableFormField, elementIsSelectElement, getAttributeBoolean, + nodeIsAnchorElement, nodeIsButtonElement, nodeIsTypeSubmitElement, sendExtensionMessage, @@ -434,6 +435,12 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ formElement.addEventListener(EVENTS.SUBMIT, this.handleFormFieldSubmitEvent); const closesSubmitButton = await this.findSubmitButton(formElement); + + if (!closesSubmitButton) { + await this.setupSubmitListenerOnFormlessField(formFieldElement); + return; + } + this.setupSubmitButtonEventListeners(closesSubmitButton); } } @@ -508,6 +515,14 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ if (submitButtonElement) { return submitButtonElement; } + + // If the submit button is not a traditional button element, check for an anchor element that contains submission keywords. + const submitAnchorElement = await this.querySubmitButtonElement(element, "a", (node: Node) => + nodeIsAnchorElement(node), + ); + if (submitAnchorElement) { + return submitAnchorElement; + } } /** diff --git a/apps/browser/src/autofill/utils/index.ts b/apps/browser/src/autofill/utils/index.ts index f2790d5532..ef52a30243 100644 --- a/apps/browser/src/autofill/utils/index.ts +++ b/apps/browser/src/autofill/utils/index.ts @@ -323,6 +323,10 @@ export function nodeIsButtonElement(node: Node): node is HTMLButtonElement { ); } +export function nodeIsAnchorElement(node: Node): node is HTMLAnchorElement { + return nodeIsElement(node) && elementIsInstanceOf(node, "a"); +} + /** * Returns a boolean representing the attribute value of an element. *