[PM-8833] Reworking how the inline menu is opened and positioned to act more uniformly

This commit is contained in:
Cesar Gonzalez 2024-09-24 08:38:36 -05:00
parent 065299a27e
commit a2b4c2f40a
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
2 changed files with 23 additions and 23 deletions

View File

@ -18,12 +18,12 @@ export type NotificationFormFieldData = {
export type AutofillOverlayContentExtensionMessageHandlers = {
[key: string]: CallableFunction;
addNewVaultItemFromOverlay: ({ message }: AutofillExtensionMessageParam) => void;
blurMostRecentlyFocusedField: () => void;
blurMostRecentlyFocusedField: () => Promise<void>;
focusMostRecentlyFocusedField: () => void;
unsetMostRecentlyFocusedField: () => void;
checkIsMostRecentlyFocusedFieldWithinViewport: () => Promise<boolean>;
bgUnlockPopoutOpened: () => void;
bgVaultItemRepromptPopoutOpened: () => void;
bgUnlockPopoutOpened: () => Promise<void>;
bgVaultItemRepromptPopoutOpened: () => Promise<void>;
redirectAutofillInlineMenuFocusOut: ({ message }: AutofillExtensionMessageParam) => void;
updateAutofillInlineMenuVisibility: ({ message }: AutofillExtensionMessageParam) => void;
getSubFrameOffsets: ({ message }: AutofillExtensionMessageParam) => Promise<SubFrameOffsetData>;

View File

@ -200,36 +200,22 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
await this.setupOverlayListenersOnQualifiedField(formFieldElement, autofillFieldData);
}
/**
* Focuses the most recently focused field element.
*/
focusMostRecentlyFocusedField() {
this.mostRecentlyFocusedField?.focus();
}
/**
* Removes focus from the most recently focused field element.
*/
blurMostRecentlyFocusedField(isClosingInlineMenu: boolean = false) {
async blurMostRecentlyFocusedField(isClosingInlineMenu: boolean = false) {
this.mostRecentlyFocusedField?.blur();
if (isClosingInlineMenu) {
void this.sendExtensionMessage("closeAutofillInlineMenu");
await this.sendExtensionMessage("closeAutofillInlineMenu", { forceCloseInlineMenu: true });
}
}
/**
* Sets the most recently focused field within the current frame to a `null` value.
*/
unsetMostRecentlyFocusedField() {
this.mostRecentlyFocusedField = null;
}
/**
* Formats any found user filled fields for a login cipher and sends a message
* to the background script to add a new cipher.
*/
async addNewVaultItem({ addNewCipherType }: AutofillExtensionMessage) {
private async addNewVaultItem({ addNewCipherType }: AutofillExtensionMessage) {
const command = "autofillOverlayAddNewVaultItem";
const password =
this.userFilledFields["newPassword"]?.value || this.userFilledFields["password"]?.value;
@ -242,7 +228,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
hostname: globalThis.document.location.hostname,
};
void this.sendExtensionMessage(command, { addNewCipherType, login });
await this.sendExtensionMessage(command, { addNewCipherType, login });
return;
}
@ -257,7 +243,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
cvv: this.userFilledFields["cardCvv"]?.value || "",
};
void this.sendExtensionMessage(command, { addNewCipherType, card });
await this.sendExtensionMessage(command, { addNewCipherType, card });
return;
}
@ -282,10 +268,24 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
username: this.userFilledFields["identityUsername"]?.value || "",
};
void this.sendExtensionMessage(command, { addNewCipherType, identity });
await this.sendExtensionMessage(command, { addNewCipherType, identity });
}
}
/**
* Focuses the most recently focused field element.
*/
private focusMostRecentlyFocusedField() {
this.mostRecentlyFocusedField?.focus();
}
/**
* Sets the most recently focused field within the current frame to a `null` value.
*/
private unsetMostRecentlyFocusedField() {
this.mostRecentlyFocusedField = null;
}
/**
* Redirects the keyboard focus out of the inline menu, selecting the element that is
* either previous or next in the tab order. If the direction is current, the most