1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[PM-14054] Fixing scroll-based repositioning of inline menu when inline menu is focused (#11770)

This commit is contained in:
Cesar Gonzalez
2024-10-29 16:55:40 -05:00
committed by GitHub
parent d50e8bbf4c
commit 896d19551a
4 changed files with 11 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ import AutofillInit from "./autofill-init";
domQueryService, domQueryService,
domElementVisibilityService, domElementVisibilityService,
inlineMenuFieldQualificationService, inlineMenuFieldQualificationService,
inlineMenuContentService,
); );
windowContext.bitwardenAutofillInit = new AutofillInit( windowContext.bitwardenAutofillInit = new AutofillInit(

View File

@@ -24,6 +24,7 @@ import AutofillInit from "./autofill-init";
domQueryService, domQueryService,
domElementVisibilityService, domElementVisibilityService,
inlineMenuFieldQualificationService, inlineMenuFieldQualificationService,
inlineMenuContentService,
); );
windowContext.bitwardenAutofillInit = new AutofillInit( windowContext.bitwardenAutofillInit = new AutofillInit(

View File

@@ -1,4 +1,4 @@
import { mock } from "jest-mock-extended"; import { mock, MockProxy } from "jest-mock-extended";
import { EVENTS } from "@bitwarden/common/autofill/constants"; import { EVENTS } from "@bitwarden/common/autofill/constants";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
@@ -13,6 +13,7 @@ import {
import AutofillField from "../models/autofill-field"; import AutofillField from "../models/autofill-field";
import AutofillForm from "../models/autofill-form"; import AutofillForm from "../models/autofill-form";
import AutofillPageDetails from "../models/autofill-page-details"; import AutofillPageDetails from "../models/autofill-page-details";
import { AutofillInlineMenuContentService } from "../overlay/inline-menu/abstractions/autofill-inline-menu-content.service";
import { createAutofillFieldMock } from "../spec/autofill-mocks"; import { createAutofillFieldMock } from "../spec/autofill-mocks";
import { import {
flushPromises, flushPromises,
@@ -35,6 +36,7 @@ describe("AutofillOverlayContentService", () => {
let domElementVisibilityService: DomElementVisibilityService; let domElementVisibilityService: DomElementVisibilityService;
let autofillInit: AutofillInit; let autofillInit: AutofillInit;
let inlineMenuFieldQualificationService: InlineMenuFieldQualificationService; let inlineMenuFieldQualificationService: InlineMenuFieldQualificationService;
let inlineMenuContentService: MockProxy<AutofillInlineMenuContentService>;
let autofillOverlayContentService: AutofillOverlayContentService; let autofillOverlayContentService: AutofillOverlayContentService;
let sendExtensionMessageSpy: jest.SpyInstance; let sendExtensionMessageSpy: jest.SpyInstance;
const sendResponseSpy = jest.fn(); const sendResponseSpy = jest.fn();
@@ -44,10 +46,12 @@ describe("AutofillOverlayContentService", () => {
inlineMenuFieldQualificationService = new InlineMenuFieldQualificationService(); inlineMenuFieldQualificationService = new InlineMenuFieldQualificationService();
domQueryService = new DomQueryService(); domQueryService = new DomQueryService();
domElementVisibilityService = new DomElementVisibilityService(); domElementVisibilityService = new DomElementVisibilityService();
inlineMenuContentService = mock<AutofillInlineMenuContentService>();
autofillOverlayContentService = new AutofillOverlayContentService( autofillOverlayContentService = new AutofillOverlayContentService(
domQueryService, domQueryService,
domElementVisibilityService, domElementVisibilityService,
inlineMenuFieldQualificationService, inlineMenuFieldQualificationService,
inlineMenuContentService,
); );
autofillInit = new AutofillInit( autofillInit = new AutofillInit(
domQueryService, domQueryService,

View File

@@ -28,6 +28,7 @@ import {
} from "../enums/autofill-overlay.enum"; } from "../enums/autofill-overlay.enum";
import AutofillField from "../models/autofill-field"; import AutofillField from "../models/autofill-field";
import AutofillPageDetails from "../models/autofill-page-details"; import AutofillPageDetails from "../models/autofill-page-details";
import { AutofillInlineMenuContentService } from "../overlay/inline-menu/abstractions/autofill-inline-menu-content.service";
import { ElementWithOpId, FillableFormFieldElement, FormFieldElement } from "../types"; import { ElementWithOpId, FillableFormFieldElement, FormFieldElement } from "../types";
import { import {
currentlyInSandboxedIframe, currentlyInSandboxedIframe,
@@ -155,6 +156,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
private domQueryService: DomQueryService, private domQueryService: DomQueryService,
private domElementVisibilityService: DomElementVisibilityService, private domElementVisibilityService: DomElementVisibilityService,
private inlineMenuFieldQualificationService: InlineMenuFieldQualificationService, private inlineMenuFieldQualificationService: InlineMenuFieldQualificationService,
private inlineMenuContentService?: AutofillInlineMenuContentService,
) {} ) {}
/** /**
@@ -1580,7 +1582,8 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
if (activeElement) { if (activeElement) {
return ( return (
activeElement === this.mostRecentlyFocusedField || activeElement === this.mostRecentlyFocusedField ||
activeElement.contains(this.mostRecentlyFocusedField) activeElement.contains(this.mostRecentlyFocusedField) ||
this.inlineMenuContentService?.isElementInlineMenu(activeElement as HTMLElement)
); );
} }