Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Pinned messages menu: jumping to a pinned message puts focus back on the menu's button

luishron12301624745b959
diff --git a/src/components/PinnedMessagesMenu.dom.test.ts b/src/components/PinnedMessagesMenu.dom.test.ts
index 777216dce9..f9a12d6cf3 100644
--- a/src/components/PinnedMessagesMenu.dom.test.ts
+++ b/src/components/PinnedMessagesMenu.dom.test.ts
@@ -27,7 +27,7 @@ it("shows no button while nothing is pinned", async () => {
act(() => root.unmount());
});
-it("lists who said the pinned message and what, and jumps to it", async () => {
+it("lists who said the pinned message and what, and jumps to it with focus back on its button", async () => {
const { root, onJump } = await mount();
expect(document.querySelector("[role=menu]")).toBeNull();
await act(async () => trigger()!.click());
@@ -37,6 +37,7 @@ it("lists who said the pinned message and what, and jumps to it", async () => {
await act(async () => items()[0]!.click());
expect(onJump).toHaveBeenCalledWith("m1");
expect(trigger()!.getAttribute("aria-expanded")).toBe("false");
+ expect(document.activeElement).toBe(trigger());
act(() => root.unmount());
});
diff --git a/src/components/PinnedMessagesMenu.tsx b/src/components/PinnedMessagesMenu.tsx
index e7488408b8..bd9d2383fd 100644
--- a/src/components/PinnedMessagesMenu.tsx
+++ b/src/components/PinnedMessagesMenu.tsx
@@ -106,7 +106,7 @@ export function PinnedMessagesMenu({ pins, onJump, onUnpin, triggerClassName }:
role="menuitem"
data-pinned-jump={pin.id}
title={t("chat.pinnedJump")}
- onClick={() => { setOpen(false); onJump(pin.id); }}
+ onClick={() => { close(); onJump(pin.id); }}
className={cn(SIMPLE_MENU_ROW, "flex-1 flex-col items-start gap-0 py-1.5")}
>
<span className={SIMPLE_MENU_META}>{pin.sender}</span>