1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 14:23:32 +00:00

[PM-10550] Card inline menu not displayed on popup payment form (#10380)

* [PM-10550] Card inline menu not displayed on popup payment form

* [PM-10550] Removing requirement for autocomplete to be "off" for identity fields when matching inline menu presentation
This commit is contained in:
Cesar Gonzalez
2024-08-02 14:30:23 -05:00
committed by GitHub
parent 76351ce750
commit 032c013dd7

View File

@@ -209,10 +209,7 @@ export class InlineMenuFieldQualificationService
return false; return false;
} }
return ( return this.keywordsFoundInFieldData(field, this.creditCardFieldKeywords);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, this.creditCardFieldKeywords)
);
} }
// If the field has a parent form, check the fields from that form exclusively // If the field has a parent form, check the fields from that form exclusively
@@ -232,10 +229,7 @@ export class InlineMenuFieldQualificationService
return false; return false;
} }
return ( return this.keywordsFoundInFieldData(field, [...this.creditCardFieldKeywords]);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, [...this.creditCardFieldKeywords])
);
} }
/** Validates the provided field as a field for an account creation form. /** Validates the provided field as a field for an account creation form.
@@ -264,10 +258,7 @@ export class InlineMenuFieldQualificationService
// If no password fields are found on the page, check for keywords that indicate the field is // If no password fields are found on the page, check for keywords that indicate the field is
// part of an account creation form. // part of an account creation form.
return ( return this.keywordsFoundInFieldData(field, this.accountCreationFieldKeywords);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, this.accountCreationFieldKeywords)
);
} }
// If the field has a parent form, check the fields from that form exclusively // If the field has a parent form, check the fields from that form exclusively
@@ -277,10 +268,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, this.accountCreationFieldKeywords);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, this.accountCreationFieldKeywords)
);
} }
/** /**
@@ -298,10 +286,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, this.identityFieldKeywords);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, this.identityFieldKeywords)
);
} }
/** /**
@@ -480,9 +465,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, CreditCardAutoFillConstants.CardHolderFieldNames, false) CreditCardAutoFillConstants.CardHolderFieldNames,
false,
); );
}; };
@@ -496,9 +482,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, CreditCardAutoFillConstants.CardNumberFieldNames, false) CreditCardAutoFillConstants.CardNumberFieldNames,
false,
); );
}; };
@@ -514,9 +501,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, CreditCardAutoFillConstants.CardExpiryFieldNames, false) CreditCardAutoFillConstants.CardExpiryFieldNames,
false,
); );
}; };
@@ -532,9 +520,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, CreditCardAutoFillConstants.ExpiryMonthFieldNames, false) CreditCardAutoFillConstants.ExpiryMonthFieldNames,
false,
); );
}; };
@@ -550,9 +539,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, CreditCardAutoFillConstants.ExpiryYearFieldNames, false) CreditCardAutoFillConstants.ExpiryYearFieldNames,
false,
); );
}; };
@@ -566,10 +556,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, CreditCardAutoFillConstants.CVVFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, CreditCardAutoFillConstants.CVVFieldNames, false)
);
}; };
/** /**
@@ -584,10 +571,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.TitleFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.TitleFieldNames, false)
);
}; };
/** /**
@@ -600,9 +584,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.FirstnameFieldNames, false) IdentityAutoFillConstants.FirstnameFieldNames,
false,
); );
}; };
@@ -616,9 +601,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.MiddlenameFieldNames, false) IdentityAutoFillConstants.MiddlenameFieldNames,
false,
); );
}; };
@@ -632,9 +618,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.LastnameFieldNames, false) IdentityAutoFillConstants.LastnameFieldNames,
false,
); );
}; };
@@ -648,9 +635,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.FullNameFieldNames, false) IdentityAutoFillConstants.FullNameFieldNames,
false,
); );
}; };
@@ -664,16 +652,13 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData( [
field, ...IdentityAutoFillConstants.AddressFieldNames,
[ ...IdentityAutoFillConstants.Address1FieldNames,
...IdentityAutoFillConstants.AddressFieldNames, ],
...IdentityAutoFillConstants.Address1FieldNames, false,
],
false,
)
); );
}; };
@@ -687,9 +672,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.Address2FieldNames, false) IdentityAutoFillConstants.Address2FieldNames,
false,
); );
}; };
@@ -703,9 +689,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.Address3FieldNames, false) IdentityAutoFillConstants.Address3FieldNames,
false,
); );
}; };
@@ -719,10 +706,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.CityFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.CityFieldNames, false)
);
}; };
/** /**
@@ -735,10 +719,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.StateFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.StateFieldNames, false)
);
}; };
/** /**
@@ -751,9 +732,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.PostalCodeFieldNames, false) IdentityAutoFillConstants.PostalCodeFieldNames,
false,
); );
}; };
@@ -767,10 +749,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.CountryFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.CountryFieldNames, false)
);
}; };
/** /**
@@ -783,10 +762,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.CompanyFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.CompanyFieldNames, false)
);
}; };
/** /**
@@ -799,10 +775,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.PhoneFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.PhoneFieldNames, false)
);
}; };
/** /**
@@ -818,10 +791,7 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.EmailFieldNames, false);
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) &&
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.EmailFieldNames, false)
);
}; };
/** /**
@@ -834,9 +804,10 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
return ( return this.keywordsFoundInFieldData(
!this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues) && field,
this.keywordsFoundInFieldData(field, IdentityAutoFillConstants.UserNameFieldNames, false) IdentityAutoFillConstants.UserNameFieldNames,
false,
); );
}; };
@@ -1039,11 +1010,13 @@ export class InlineMenuFieldQualificationService
fuzzyMatchKeywords = true, fuzzyMatchKeywords = true,
) { ) {
const searchedValues = this.getAutofillFieldDataKeywords(autofillFieldData, fuzzyMatchKeywords); const searchedValues = this.getAutofillFieldDataKeywords(autofillFieldData, fuzzyMatchKeywords);
const parsedKeywords = keywords.map((keyword) => keyword.replace(/-/g, ""));
if (typeof searchedValues === "string") { if (typeof searchedValues === "string") {
return keywords.some((keyword) => searchedValues.indexOf(keyword) > -1); return parsedKeywords.some((keyword) => searchedValues.indexOf(keyword) > -1);
} }
return keywords.some((keyword) => searchedValues.has(keyword)); return parsedKeywords.some((keyword) => searchedValues.has(keyword));
} }
/** /**
@@ -1057,7 +1030,7 @@ export class InlineMenuFieldQualificationService
returnStringValue: boolean, returnStringValue: boolean,
) { ) {
if (!this.autofillFieldKeywordsMap.has(autofillFieldData)) { if (!this.autofillFieldKeywordsMap.has(autofillFieldData)) {
const keywordsSet = new Set<string>([ const keywords = [
autofillFieldData.htmlID, autofillFieldData.htmlID,
autofillFieldData.htmlName, autofillFieldData.htmlName,
autofillFieldData.htmlClass, autofillFieldData.htmlClass,
@@ -1071,8 +1044,20 @@ export class InlineMenuFieldQualificationService
autofillFieldData["label-right"], autofillFieldData["label-right"],
autofillFieldData["label-tag"], autofillFieldData["label-tag"],
autofillFieldData["label-top"], autofillFieldData["label-top"],
]); ];
const stringValue = Array.from(keywordsSet).join(",").toLowerCase(); const keywordsSet = new Set<string>();
for (let i = 0; i < keywords.length; i++) {
if (typeof keywords[i] === "string") {
keywords[i]
.toLowerCase()
.replace(/-/g, "")
.replace(/[^a-zA-Z0-9]+/g, "|")
.split("|")
.forEach((keyword) => keywordsSet.add(keyword));
}
}
const stringValue = Array.from(keywordsSet).join(",");
this.autofillFieldKeywordsMap.set(autofillFieldData, { keywordsSet, stringValue }); this.autofillFieldKeywordsMap.set(autofillFieldData, { keywordsSet, stringValue });
} }