mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
Autofill form that has the focus (#16499)
This commit is contained in:
@@ -48,6 +48,7 @@ export type FocusedFieldData = {
|
|||||||
frameId?: number;
|
frameId?: number;
|
||||||
accountCreationFieldType?: string;
|
accountCreationFieldType?: string;
|
||||||
showPasskeys?: boolean;
|
showPasskeys?: boolean;
|
||||||
|
focusedFieldForm?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InlineMenuElementPosition = {
|
export type InlineMenuElementPosition = {
|
||||||
|
|||||||
@@ -1175,6 +1175,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
pageDetails,
|
pageDetails,
|
||||||
fillNewPassword: true,
|
fillNewPassword: true,
|
||||||
allowTotpAutofill: true,
|
allowTotpAutofill: true,
|
||||||
|
focusedFieldForm: this.focusedFieldData?.focusedFieldForm,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (totpCode) {
|
if (totpCode) {
|
||||||
@@ -1859,6 +1860,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
pageDetails,
|
pageDetails,
|
||||||
fillNewPassword: true,
|
fillNewPassword: true,
|
||||||
allowTotpAutofill: false,
|
allowTotpAutofill: false,
|
||||||
|
focusedFieldForm: this.focusedFieldData?.focusedFieldForm,
|
||||||
});
|
});
|
||||||
|
|
||||||
globalThis.setTimeout(async () => {
|
globalThis.setTimeout(async () => {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export interface AutoFillOptions {
|
|||||||
allowUntrustedIframe?: boolean;
|
allowUntrustedIframe?: boolean;
|
||||||
allowTotpAutofill?: boolean;
|
allowTotpAutofill?: boolean;
|
||||||
autoSubmitLogin?: boolean;
|
autoSubmitLogin?: boolean;
|
||||||
|
focusedFieldForm?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormData {
|
export interface FormData {
|
||||||
|
|||||||
@@ -974,6 +974,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
inlineMenuFillType: autofillFieldData?.inlineMenuFillType,
|
inlineMenuFillType: autofillFieldData?.inlineMenuFillType,
|
||||||
showPasskeys: !!autofillFieldData?.showPasskeys,
|
showPasskeys: !!autofillFieldData?.showPasskeys,
|
||||||
accountCreationFieldType: autofillFieldData?.accountCreationFieldType,
|
accountCreationFieldType: autofillFieldData?.accountCreationFieldType,
|
||||||
|
focusedFieldForm: autofillFieldData?.form,
|
||||||
};
|
};
|
||||||
|
|
||||||
const allFields = this.formFieldElements;
|
const allFields = this.formFieldElements;
|
||||||
|
|||||||
@@ -434,7 +434,15 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fillScript = await this.generateFillScript(pd.details, {
|
// If we have a focused form, filter the page details to only include fields from that form
|
||||||
|
const details = options.focusedFieldForm
|
||||||
|
? {
|
||||||
|
...pd.details,
|
||||||
|
fields: pd.details.fields.filter((f) => f.form === options.focusedFieldForm),
|
||||||
|
}
|
||||||
|
: pd.details;
|
||||||
|
|
||||||
|
const fillScript = await this.generateFillScript(details, {
|
||||||
skipUsernameOnlyFill: options.skipUsernameOnlyFill || false,
|
skipUsernameOnlyFill: options.skipUsernameOnlyFill || false,
|
||||||
onlyEmptyFields: options.onlyEmptyFields || false,
|
onlyEmptyFields: options.onlyEmptyFields || false,
|
||||||
fillNewPassword: options.fillNewPassword || false,
|
fillNewPassword: options.fillNewPassword || false,
|
||||||
|
|||||||
Reference in New Issue
Block a user