1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

Autofill form that has the focus (#16499)

This commit is contained in:
Jeffrey Holland
2025-09-26 11:17:41 +02:00
committed by GitHub
parent 4a9183adc5
commit fd98dda0a5
5 changed files with 14 additions and 1 deletions

View File

@@ -48,6 +48,7 @@ export type FocusedFieldData = {
frameId?: number;
accountCreationFieldType?: string;
showPasskeys?: boolean;
focusedFieldForm?: string;
};
export type InlineMenuElementPosition = {

View File

@@ -1175,6 +1175,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
pageDetails,
fillNewPassword: true,
allowTotpAutofill: true,
focusedFieldForm: this.focusedFieldData?.focusedFieldForm,
});
if (totpCode) {
@@ -1859,6 +1860,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
pageDetails,
fillNewPassword: true,
allowTotpAutofill: false,
focusedFieldForm: this.focusedFieldData?.focusedFieldForm,
});
globalThis.setTimeout(async () => {

View File

@@ -30,6 +30,7 @@ export interface AutoFillOptions {
allowUntrustedIframe?: boolean;
allowTotpAutofill?: boolean;
autoSubmitLogin?: boolean;
focusedFieldForm?: string;
}
export interface FormData {

View File

@@ -974,6 +974,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
inlineMenuFillType: autofillFieldData?.inlineMenuFillType,
showPasskeys: !!autofillFieldData?.showPasskeys,
accountCreationFieldType: autofillFieldData?.accountCreationFieldType,
focusedFieldForm: autofillFieldData?.form,
};
const allFields = this.formFieldElements;

View File

@@ -434,7 +434,15 @@ export default class AutofillService implements AutofillServiceInterface {
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,
onlyEmptyFields: options.onlyEmptyFields || false,
fillNewPassword: options.fillNewPassword || false,