1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

[PM-5189] Fixing an issue with how scroll events trigger a reposition of the inline menu when the field is not focused;

This commit is contained in:
Cesar Gonzalez
2024-06-12 13:32:20 -05:00
parent c69a82a304
commit b1e75ad7b5
2 changed files with 1 additions and 30 deletions

View File

@@ -1222,13 +1222,6 @@ describe("OverlayBackground", () => {
frameId: 2, frameId: 2,
}); });
beforeEach(() => {
sendMockExtensionMessage({
command: "updateIsFieldCurrentlyFocused",
isFieldCurrentlyFocused: true,
});
});
it("returns false if the focused field data is not set", async () => { it("returns false if the focused field data is not set", async () => {
sendMockExtensionMessage( sendMockExtensionMessage(
{ command: "checkShouldRepositionInlineMenu" }, { command: "checkShouldRepositionInlineMenu" },
@@ -1258,24 +1251,6 @@ describe("OverlayBackground", () => {
expect(sendResponse).toHaveBeenCalledWith(false); expect(sendResponse).toHaveBeenCalledWith(false);
}); });
it("returns false if the field is not currently focused", async () => {
sendMockExtensionMessage({
command: "updateIsFieldCurrentlyFocused",
isFieldCurrentlyFocused: false,
});
const focusedFieldData = createFocusedFieldDataMock();
sendMockExtensionMessage({ command: "updateFocusedFieldData", focusedFieldData }, sender);
sendMockExtensionMessage(
{ command: "checkShouldRepositionInlineMenu" },
sender,
sendResponse,
);
await flushPromises();
expect(sendResponse).toHaveBeenCalledWith(false);
});
it("returns true if the focused field's frame id is equal to the sender's frame id", async () => { it("returns true if the focused field's frame id is equal to the sender's frame id", async () => {
const focusedFieldData = createFocusedFieldDataMock(); const focusedFieldData = createFocusedFieldDataMock();
sendMockExtensionMessage({ command: "updateFocusedFieldData", focusedFieldData }, sender); sendMockExtensionMessage({ command: "updateFocusedFieldData", focusedFieldData }, sender);

View File

@@ -1024,11 +1024,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
* @param sender - The sender of the message * @param sender - The sender of the message
*/ */
private checkShouldRepositionInlineMenu(sender: chrome.runtime.MessageSender): boolean { private checkShouldRepositionInlineMenu(sender: chrome.runtime.MessageSender): boolean {
if ( if (!this.focusedFieldData || sender.tab.id !== this.focusedFieldData.tabId) {
!this.focusedFieldData ||
sender.tab.id !== this.focusedFieldData.tabId ||
!this.isFieldCurrentlyFocused
) {
return false; return false;
} }