From 7436f9112ddc044674eca7668f1b8584ed2b6d47 Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Tue, 23 Jan 2024 16:26:37 -0600 Subject: [PATCH] [PM-5806] Remove the Inline Auto-fill Menu From `textarea` Fields (#7655) * [PM-5806] Remove the autofill overlay menu from textarea fields * [PM-5806] Running prettier * [PM-5806] Implementing a new AutofillConstant to more easily exclude overlay types * [PM-5806] Implementing a new AutofillConstant to more easily exclude overlay types --- apps/browser/src/autofill/services/autofill-constants.ts | 5 +++++ .../services/autofill-overlay-content.service.spec.ts | 4 ++-- .../autofill/services/autofill-overlay-content.service.ts | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/browser/src/autofill/services/autofill-constants.ts b/apps/browser/src/autofill/services/autofill-constants.ts index 2f16f4e35e..f6d0f10939 100644 --- a/apps/browser/src/autofill/services/autofill-constants.ts +++ b/apps/browser/src/autofill/services/autofill-constants.ts @@ -65,6 +65,11 @@ export class AutoFillConstants { "checkbox", ...AutoFillConstants.ExcludedAutofillLoginTypes, ]; + + static readonly ExcludedOverlayTypes: string[] = [ + "textarea", + ...AutoFillConstants.ExcludedAutofillTypes, + ]; } export class CreditCardAutoFillConstants { diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts index 01d63ca8f2..a6f7ba710b 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts @@ -195,8 +195,8 @@ describe("AutofillOverlayContentService", () => { expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled(); }); - it("ignores fields that are part of the ExcludedAutofillTypes", () => { - AutoFillConstants.ExcludedAutofillTypes.forEach((excludedType) => { + it("ignores fields that are part of the ExcludedOverlayTypes", () => { + AutoFillConstants.ExcludedOverlayTypes.forEach((excludedType) => { autofillFieldData.type = excludedType; autofillOverlayContentService.setupAutofillOverlayListenerOnField( 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 4234e0cf4f..55bfc32755 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts @@ -32,6 +32,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte private readonly findTabs = tabbable; private readonly sendExtensionMessage = sendExtensionMessage; private formFieldElements: Set> = new Set([]); + private ignoredFieldTypes: Set = new Set(AutoFillConstants.ExcludedOverlayTypes); private userFilledFields: Record = {}; private authStatus: AuthenticationStatus; private focusableElements: FocusableElement[] = []; @@ -715,12 +716,11 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte * @param autofillFieldData - Autofill field data captured from the form field element. */ private isIgnoredField(autofillFieldData: AutofillField): boolean { - const ignoredFieldTypes = new Set(AutoFillConstants.ExcludedAutofillTypes); if ( autofillFieldData.readonly || autofillFieldData.disabled || !autofillFieldData.viewable || - ignoredFieldTypes.has(autofillFieldData.type) || + this.ignoredFieldTypes.has(autofillFieldData.type) || this.keywordsFoundInFieldData(autofillFieldData, ["search", "captcha"]) ) { return true;