Skip to content

Commit

Permalink
[PM-5806] Remove the Inline Auto-fill Menu From textarea Fields (#7655
Browse files Browse the repository at this point in the history
)

* [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
  • Loading branch information
cagonzalezcs authored Jan 23, 2024
1 parent 219bad0 commit 7436f91
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions apps/browser/src/autofill/services/autofill-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export class AutoFillConstants {
"checkbox",
...AutoFillConstants.ExcludedAutofillLoginTypes,
];

static readonly ExcludedOverlayTypes: string[] = [
"textarea",
...AutoFillConstants.ExcludedAutofillTypes,
];
}

export class CreditCardAutoFillConstants {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
private readonly findTabs = tabbable;
private readonly sendExtensionMessage = sendExtensionMessage;
private formFieldElements: Set<ElementWithOpId<FormFieldElement>> = new Set([]);
private ignoredFieldTypes: Set<string> = new Set(AutoFillConstants.ExcludedOverlayTypes);
private userFilledFields: Record<string, FillableFormFieldElement> = {};
private authStatus: AuthenticationStatus;
private focusableElements: FocusableElement[] = [];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7436f91

Please sign in to comment.