[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 = { export type AutofillOverlayContentExtensionMessageHandlers = {
[key: string]: CallableFunction; [key: string]: CallableFunction;
addNewVaultItemFromOverlay: ({ message }: AutofillExtensionMessageParam) => void; addNewVaultItemFromOverlay: ({ message }: AutofillExtensionMessageParam) => void;
blurMostRecentlyFocusedField: () => void; blurMostRecentlyFocusedField: () => Promise<void>;
focusMostRecentlyFocusedField: () => void; focusMostRecentlyFocusedField: () => void;
unsetMostRecentlyFocusedField: () => void; unsetMostRecentlyFocusedField: () => void;
checkIsMostRecentlyFocusedFieldWithinViewport: () => Promise<boolean>; checkIsMostRecentlyFocusedFieldWithinViewport: () => Promise<boolean>;
bgUnlockPopoutOpened: () => void; bgUnlockPopoutOpened: () => Promise<void>;
bgVaultItemRepromptPopoutOpened: () => void; bgVaultItemRepromptPopoutOpened: () => Promise<void>;
redirectAutofillInlineMenuFocusOut: ({ message }: AutofillExtensionMessageParam) => void; redirectAutofillInlineMenuFocusOut: ({ message }: AutofillExtensionMessageParam) => void;
updateAutofillInlineMenuVisibility: ({ message }: AutofillExtensionMessageParam) => void; updateAutofillInlineMenuVisibility: ({ message }: AutofillExtensionMessageParam) => void;
getSubFrameOffsets: ({ message }: AutofillExtensionMessageParam) => Promise<SubFrameOffsetData>; getSubFrameOffsets: ({ message }: AutofillExtensionMessageParam) => Promise<SubFrameOffsetData>;

View File

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