Skip to content

Commit

Permalink
feat: prompt when autofilled
Browse files Browse the repository at this point in the history
  • Loading branch information
dbajpeyi committed Nov 25, 2024
1 parent e1030b4 commit d8c7d83
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
5 changes: 4 additions & 1 deletion dist/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion dist/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,15 @@ class Form {

// After autofill we check if form values match the data provided…
const formValues = this.getValuesReadyForStorage();
const hasOnlyOneCredential =
(Boolean(formValues.credentials?.username) && !formValues.credentials?.password) ||
(Boolean(formValues.credentials?.password) && !formValues.credentials?.username);
const areAllFormValuesKnown = Object.keys(formValues[dataType] || {}).every(
(subtype) => formValues[dataType][subtype] === data[subtype],
);
if (areAllFormValuesKnown) {
// If all form values are known, but we only have a single credntial field - then we want to prompt a partial save with username,
// So that in multi step forms (like reset-password), we can identify which username was picked, or complete a password save.
if (areAllFormValuesKnown && !hasOnlyOneCredential) {
// …if we know all the values do not prompt to store data
this.shouldPromptToStoreData = false;
// reset this to its initial value
Expand Down
5 changes: 4 additions & 1 deletion swift-package/Resources/assets/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion swift-package/Resources/assets/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d8c7d83

Please sign in to comment.