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:
@@ -48,6 +48,7 @@ export type FocusedFieldData = {
|
||||
frameId?: number;
|
||||
accountCreationFieldType?: string;
|
||||
showPasskeys?: boolean;
|
||||
focusedFieldForm?: string;
|
||||
};
|
||||
|
||||
export type InlineMenuElementPosition = {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface AutoFillOptions {
|
||||
allowUntrustedIframe?: boolean;
|
||||
allowTotpAutofill?: boolean;
|
||||
autoSubmitLogin?: boolean;
|
||||
focusedFieldForm?: string;
|
||||
}
|
||||
|
||||
export interface FormData {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user