mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-06 23:51:28 +01:00
[PM-5189] Fixing issues with how we handle repositioning the inline menu
This commit is contained in:
parent
3e13cbfb5c
commit
6a1a684435
@ -112,6 +112,7 @@ type OverlayBackgroundExtensionMessageHandlers = {
|
|||||||
updateIsFieldCurrentlyFilling: ({ message }: BackgroundMessageParam) => void;
|
updateIsFieldCurrentlyFilling: ({ message }: BackgroundMessageParam) => void;
|
||||||
checkIsInlineMenuButtonVisible: ({ sender }: BackgroundSenderParam) => void;
|
checkIsInlineMenuButtonVisible: ({ sender }: BackgroundSenderParam) => void;
|
||||||
checkIsInlineMenuListVisible: ({ sender }: BackgroundSenderParam) => void;
|
checkIsInlineMenuListVisible: ({ sender }: BackgroundSenderParam) => void;
|
||||||
|
checkIsInlineMenuCiphersPopulated: ({ sender }: BackgroundSenderParam) => void;
|
||||||
updateSubFrameData: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
updateSubFrameData: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||||
rebuildSubFrameOffsets: ({ sender }: BackgroundSenderParam) => void;
|
rebuildSubFrameOffsets: ({ sender }: BackgroundSenderParam) => void;
|
||||||
};
|
};
|
||||||
|
@ -85,6 +85,8 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
(this.isCurrentlyFilling = message.isFieldCurrentlyFilling),
|
(this.isCurrentlyFilling = message.isFieldCurrentlyFilling),
|
||||||
checkIsInlineMenuButtonVisible: ({ sender }) => this.checkIsInlineMenuButtonVisible(sender),
|
checkIsInlineMenuButtonVisible: ({ sender }) => this.checkIsInlineMenuButtonVisible(sender),
|
||||||
checkIsInlineMenuListVisible: ({ sender }) => this.checkIsInlineMenuListVisible(sender),
|
checkIsInlineMenuListVisible: ({ sender }) => this.checkIsInlineMenuListVisible(sender),
|
||||||
|
checkIsInlineMenuCiphersPopulated: ({ sender }) =>
|
||||||
|
this.checkIsInlineMenuCiphersPopulated(sender),
|
||||||
updateSubFrameData: ({ message, sender }) => this.updateSubFrameData(message, sender),
|
updateSubFrameData: ({ message, sender }) => this.updateSubFrameData(message, sender),
|
||||||
rebuildSubFrameOffsets: ({ sender }) => this.rebuildSubFrameOffsets(sender),
|
rebuildSubFrameOffsets: ({ sender }) => this.rebuildSubFrameOffsets(sender),
|
||||||
};
|
};
|
||||||
@ -137,6 +139,10 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private checkIsInlineMenuCiphersPopulated(sender: chrome.runtime.MessageSender) {
|
||||||
|
return sender.tab.id === this.focusedFieldData.tabId && this.overlayLoginCiphers.size > 0;
|
||||||
|
}
|
||||||
|
|
||||||
updateSubFrameData(message: any, sender: chrome.runtime.MessageSender) {
|
updateSubFrameData(message: any, sender: chrome.runtime.MessageSender) {
|
||||||
const subFrameOffsetsForTab = this.subFrameOffsetsForTab[sender.tab.id];
|
const subFrameOffsetsForTab = this.subFrameOffsetsForTab[sender.tab.id];
|
||||||
if (subFrameOffsetsForTab) {
|
if (subFrameOffsetsForTab) {
|
||||||
@ -199,9 +205,6 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
|
|
||||||
const ciphers = await this.getOverlayCipherData();
|
const ciphers = await this.getOverlayCipherData();
|
||||||
this.overlayListPort?.postMessage({ command: "updateOverlayListCiphers", ciphers });
|
this.overlayListPort?.postMessage({ command: "updateOverlayListCiphers", ciphers });
|
||||||
await BrowserApi.tabSendMessageData(currentTab, "updateIsOverlayCiphersPopulated", {
|
|
||||||
isOverlayCiphersPopulated: Boolean(ciphers.length),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,15 +20,11 @@ export type AutofillOverlayContentExtensionMessageHandlers = {
|
|||||||
bgVaultItemRepromptPopoutOpened: () => void;
|
bgVaultItemRepromptPopoutOpened: () => void;
|
||||||
redirectOverlayFocusOut: ({ message }: AutofillExtensionMessageParam) => void;
|
redirectOverlayFocusOut: ({ message }: AutofillExtensionMessageParam) => void;
|
||||||
updateAutofillOverlayVisibility: ({ message }: AutofillExtensionMessageParam) => void;
|
updateAutofillOverlayVisibility: ({ message }: AutofillExtensionMessageParam) => void;
|
||||||
updateIsOverlayCiphersPopulated: ({ message }: AutofillExtensionMessageParam) => void;
|
|
||||||
getSubFrameOffsets: ({ message }: AutofillExtensionMessageParam) => Promise<SubFrameOffsetData>;
|
getSubFrameOffsets: ({ message }: AutofillExtensionMessageParam) => Promise<SubFrameOffsetData>;
|
||||||
getSubFrameOffsetsFromWindowMessage: ({ message }: AutofillExtensionMessageParam) => void;
|
getSubFrameOffsetsFromWindowMessage: ({ message }: AutofillExtensionMessageParam) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface AutofillOverlayContentService {
|
export interface AutofillOverlayContentService {
|
||||||
// isFieldCurrentlyFocused: boolean;
|
|
||||||
// isCurrentlyFilling: boolean;
|
|
||||||
isOverlayCiphersPopulated: boolean;
|
|
||||||
pageDetailsUpdateRequired: boolean;
|
pageDetailsUpdateRequired: boolean;
|
||||||
autofillOverlayVisibility: number;
|
autofillOverlayVisibility: number;
|
||||||
extensionMessageHandlers: any;
|
extensionMessageHandlers: any;
|
||||||
@ -37,11 +33,6 @@ export interface AutofillOverlayContentService {
|
|||||||
autofillFieldElement: ElementWithOpId<FormFieldElement>,
|
autofillFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
autofillFieldData: AutofillField,
|
autofillFieldData: AutofillField,
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
openAutofillOverlay(options: OpenAutofillOverlayOptions): void;
|
|
||||||
// removeAutofillOverlay(): void;
|
|
||||||
// removeAutofillOverlayButton(): void;
|
|
||||||
// removeAutofillOverlayList(): void;
|
|
||||||
addNewVaultItem(): void;
|
|
||||||
focusMostRecentOverlayField(): void;
|
focusMostRecentOverlayField(): void;
|
||||||
blurMostRecentOverlayField(isRemovingOverlay?: boolean): void;
|
blurMostRecentOverlayField(isRemovingOverlay?: boolean): void;
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
|
@ -23,7 +23,6 @@ import {
|
|||||||
import { AutoFillConstants } from "./autofill-constants";
|
import { AutoFillConstants } from "./autofill-constants";
|
||||||
|
|
||||||
class AutofillOverlayContentService implements AutofillOverlayContentServiceInterface {
|
class AutofillOverlayContentService implements AutofillOverlayContentServiceInterface {
|
||||||
isOverlayCiphersPopulated = false;
|
|
||||||
pageDetailsUpdateRequired = false;
|
pageDetailsUpdateRequired = false;
|
||||||
autofillOverlayVisibility: number;
|
autofillOverlayVisibility: number;
|
||||||
private readonly findTabs = tabbable;
|
private readonly findTabs = tabbable;
|
||||||
@ -47,7 +46,6 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
bgVaultItemRepromptPopoutOpened: () => this.blurMostRecentOverlayField(true),
|
bgVaultItemRepromptPopoutOpened: () => this.blurMostRecentOverlayField(true),
|
||||||
redirectOverlayFocusOut: ({ message }) => this.redirectOverlayFocusOut(message),
|
redirectOverlayFocusOut: ({ message }) => this.redirectOverlayFocusOut(message),
|
||||||
updateAutofillOverlayVisibility: ({ message }) => this.updateAutofillOverlayVisibility(message),
|
updateAutofillOverlayVisibility: ({ message }) => this.updateAutofillOverlayVisibility(message),
|
||||||
updateIsOverlayCiphersPopulated: ({ message }) => this.updateIsOverlayCiphersPopulated(message),
|
|
||||||
getSubFrameOffsets: ({ message }) => this.getSubFrameOffsets(message),
|
getSubFrameOffsets: ({ message }) => this.getSubFrameOffsets(message),
|
||||||
getSubFrameOffsetsFromWindowMessage: ({ message }) =>
|
getSubFrameOffsetsFromWindowMessage: ({ message }) =>
|
||||||
this.getSubFrameOffsetsFromWindowMessage(message),
|
this.getSubFrameOffsetsFromWindowMessage(message),
|
||||||
@ -365,14 +363,17 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
*
|
*
|
||||||
* @param formFieldElement - The form field element that triggered the input event.
|
* @param formFieldElement - The form field element that triggered the input event.
|
||||||
*/
|
*/
|
||||||
private triggerFormFieldInput(formFieldElement: ElementWithOpId<FormFieldElement>) {
|
private async triggerFormFieldInput(formFieldElement: ElementWithOpId<FormFieldElement>) {
|
||||||
if (!elementIsFillableFormField(formFieldElement)) {
|
if (!elementIsFillableFormField(formFieldElement)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.storeModifiedFormElement(formFieldElement);
|
this.storeModifiedFormElement(formFieldElement);
|
||||||
|
|
||||||
if (formFieldElement.value && (this.isOverlayCiphersPopulated || !this.isUserAuthed())) {
|
if (
|
||||||
|
formFieldElement.value &&
|
||||||
|
((await this.isOverlayCiphersPopulated()) || !this.isUserAuthed())
|
||||||
|
) {
|
||||||
void this.sendExtensionMessage("closeAutofillOverlay", {
|
void this.sendExtensionMessage("closeAutofillOverlay", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseOverlay: true,
|
forceCloseOverlay: true,
|
||||||
@ -475,7 +476,10 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!formElementHasValue || (!this.isOverlayCiphersPopulated && this.isUserAuthed())) {
|
if (
|
||||||
|
!formElementHasValue ||
|
||||||
|
(!(await this.isOverlayCiphersPopulated()) && this.isUserAuthed())
|
||||||
|
) {
|
||||||
void this.sendExtensionMessage("openAutofillOverlay");
|
void this.sendExtensionMessage("openAutofillOverlay");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -764,9 +768,12 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
|
|
||||||
await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
|
await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
|
||||||
this.updateOverlayElementsPosition();
|
this.updateOverlayElementsPosition();
|
||||||
setTimeout(() => {
|
setTimeout(async () => {
|
||||||
this.toggleOverlayHidden(false);
|
this.toggleOverlayHidden(false);
|
||||||
if ((this.mostRecentlyFocusedField as HTMLInputElement).value) {
|
if (
|
||||||
|
(this.mostRecentlyFocusedField as HTMLInputElement).value &&
|
||||||
|
((await this.isOverlayCiphersPopulated()) || !this.isUserAuthed())
|
||||||
|
) {
|
||||||
void this.sendExtensionMessage("closeAutofillOverlay", {
|
void this.sendExtensionMessage("closeAutofillOverlay", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseOverlay: true,
|
forceCloseOverlay: true,
|
||||||
@ -946,8 +953,8 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
this.autofillOverlayVisibility = data.autofillOverlayVisibility;
|
this.autofillOverlayVisibility = data.autofillOverlayVisibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateIsOverlayCiphersPopulated({ data }: AutofillExtensionMessage) {
|
private async isOverlayCiphersPopulated() {
|
||||||
this.isOverlayCiphersPopulated = Boolean(data?.isOverlayCiphersPopulated);
|
return (await this.sendExtensionMessage("checkIsInlineMenuCiphersPopulated")) === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user