1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00

[PM-5189] Implementing fixes for how positioning of the overlay element functions

This commit is contained in:
Cesar Gonzalez
2024-03-21 12:27:12 -05:00
parent 65505f693f
commit fbd7ff2b5d
4 changed files with 17 additions and 19 deletions

View File

@@ -56,8 +56,8 @@ class OverlayBackground implements OverlayBackgroundInterface {
private overlayButtonPort: chrome.runtime.Port; private overlayButtonPort: chrome.runtime.Port;
private overlayListPort: chrome.runtime.Port; private overlayListPort: chrome.runtime.Port;
private focusedFieldData: FocusedFieldData; private focusedFieldData: FocusedFieldData;
private isFieldCurrentlyFocused: boolean; private isFieldCurrentlyFocused: boolean = false;
private isCurrentlyFilling: boolean; private isCurrentlyFilling: boolean = false;
private overlayPageTranslations: Record<string, string>; private overlayPageTranslations: Record<string, string>;
private iconsServerUrl: string; private iconsServerUrl: string;
private readonly extensionMessageHandlers: OverlayBackgroundExtensionMessageHandlers = { private readonly extensionMessageHandlers: OverlayBackgroundExtensionMessageHandlers = {
@@ -433,7 +433,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
{ overlayElement }: { overlayElement?: string }, { overlayElement }: { overlayElement?: string },
sender: chrome.runtime.MessageSender, sender: chrome.runtime.MessageSender,
) { ) {
if (!overlayElement) { if (!overlayElement || sender.tab.id !== this.focusedFieldData.tabId) {
return; return;
} }
@@ -443,10 +443,10 @@ class OverlayBackground implements OverlayBackgroundInterface {
{ frameId: 0 }, { frameId: 0 },
); );
const subFrameOffsetsForTab = this.subFrameOffsetsForTab[sender.tab.id]; const subFrameOffsetsForTab = this.subFrameOffsetsForTab[this.focusedFieldData.tabId];
let subFrameOffsets: SubFrameOffsetData; let subFrameOffsets: SubFrameOffsetData;
if (subFrameOffsetsForTab) { if (subFrameOffsetsForTab) {
subFrameOffsets = subFrameOffsetsForTab.get(sender.frameId); subFrameOffsets = subFrameOffsetsForTab.get(this.focusedFieldData.frameId);
} }
if (overlayElement === AutofillOverlayElement.Button) { if (overlayElement === AutofillOverlayElement.Button) {
@@ -814,7 +814,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
} }
const messageResponse = handler({ message, sender }); const messageResponse = handler({ message, sender });
if (!messageResponse) { if (typeof messageResponse === "undefined") {
return; return;
} }
@@ -852,14 +852,14 @@ class OverlayBackground implements OverlayBackgroundInterface {
translations: this.getTranslations(), translations: this.getTranslations(),
ciphers: isOverlayListPort ? await this.getOverlayCipherData() : null, ciphers: isOverlayListPort ? await this.getOverlayCipherData() : null,
}); });
// void this.updateOverlayPosition( void this.updateOverlayPosition(
// { {
// overlayElement: isOverlayListPort overlayElement: isOverlayListPort
// ? AutofillOverlayElement.List ? AutofillOverlayElement.List
// : AutofillOverlayElement.Button, : AutofillOverlayElement.Button,
// }, },
// port.sender, port.sender,
// ); );
}; };
/** /**

View File

@@ -236,7 +236,7 @@ export class InlineMenuElements implements InlineMenuElementsInterface {
private updateCustomElementDefaultStyles(element: HTMLElement) { private updateCustomElementDefaultStyles(element: HTMLElement) {
this.unobserveCustomElements(); this.unobserveCustomElements();
setElementStyles(element, this.customElementDefaultStyles, true); this.setElementStyles(element, this.customElementDefaultStyles, true);
this.observeCustomElements(); this.observeCustomElements();
} }

View File

@@ -542,9 +542,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
} }
if (!formElementHasValue || (!this.isOverlayCiphersPopulated && this.isUserAuthed())) { if (!formElementHasValue || (!this.isOverlayCiphersPopulated && this.isUserAuthed())) {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. void this.sendExtensionMessage("openAutofillOverlay");
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.sendExtensionMessage("openAutofillOverlay");
return; return;
} }

View File

@@ -73,7 +73,7 @@ async function sendExtensionMessage(
return new Promise((resolve) => { return new Promise((resolve) => {
chrome.runtime.sendMessage(Object.assign({ command }, options), (response) => { chrome.runtime.sendMessage(Object.assign({ command }, options), (response) => {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {
return; // Do nothing
} }
resolve(response); resolve(response);