diff --git a/frontend/src/components/PlexMenu.dom.test.tsx b/frontend/src/components/PlexMenu.dom.test.tsx index 17e29bee..ac5b2105 100644 --- a/frontend/src/components/PlexMenu.dom.test.tsx +++ b/frontend/src/components/PlexMenu.dom.test.tsx @@ -364,7 +364,9 @@ describe("a Plex title's menu — Add to collection", () => { // A menu owns its items only: the line about the list sits beside it, not in it. expect(document.querySelector("[role=menu]")).not.toBeNull(); expect(alert.closest("[role=menu]")).toBeNull(); - list.mockResolvedValue({ collections: [coll("cB", "Beta", false)] }); + list.mockResolvedValue({ + collections: [coll("cB", "Beta", false), coll("cC", "Gamma", false)], + }); // Retry from the keyboard: the focused button goes as the list loads, and focus must not be left // on
with the menu open — it lands on the first row that came back. const retry = (await screen.findByText("common.retry")).closest("button")!; @@ -372,6 +374,9 @@ describe("a Plex title's menu — Add to collection", () => { fireEvent.click(retry); const beta = await checkRow("Beta"); await vi.waitFor(() => expect(document.activeElement).toBe(beta)); + // …and the menu's own arrows carry on from there. + fireEvent.keyDown(beta, { key: "ArrowDown" }); + expect(document.activeElement).toBe(await checkRow("Gamma")); }); it("clears the name when Plex made the collection and only the read after it failed", async () => { diff --git a/frontend/src/components/ui/MembershipMenu.tsx b/frontend/src/components/ui/MembershipMenu.tsx index 2ab11c5d..5739dba6 100644 --- a/frontend/src/components/ui/MembershipMenu.tsx +++ b/frontend/src/components/ui/MembershipMenu.tsx @@ -79,18 +79,23 @@ export function MembershipMenu({ useEffect(() => { if (shownStatus.current === status) return; shownStatus.current = status; - const root = rootRef.current; - const at = document.activeElement; - // …unless a name is being typed into it meanwhile. - const parked = at === placed.current && !(at instanceof HTMLInputElement && at.value); - const lost = at == null || at === document.body || parked; - if (!root || !lost) return; - const target = - root.querySelector