Skip to content

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

Page card: keep the keyboard out of the preview under the card's button

luishron123dfcd25cce9f3
diff --git a/src/components/app/AppMessage.compact.test.ts b/src/components/app/AppMessage.compact.test.ts
index 66b5c67108..2f440939d7 100644
--- a/src/components/app/AppMessage.compact.test.ts
+++ b/src/components/app/AppMessage.compact.test.ts
@@ -54,6 +54,17 @@ afterEach(() => {
});
describe("a bot's page as a compact card", () => {
+ it("keeps the keyboard out of the preview, in a chat and in a room, and leaves the card's own buttons reachable", async () => {
+ for (const room of [false, true]) {
+ await render(row(payload()), room);
+ const box = card().querySelector<HTMLElement>("[data-app-box]")!;
+ expect(box.querySelector("iframe")).not.toBeNull();
+ expect(box.hasAttribute("inert")).toBe(true);
+ expect(opener().closest("[inert]")).toBeNull();
+ expect(card().querySelector("[data-page-footer]")!.closest("[inert]")).toBeNull();
+ }
+ });
+
it("shows only the preview and a footer with the title and what it is", async () => {
await render(row(payload()));
expect(card().querySelector<HTMLElement>("[data-app-box]")!.style.height).toBe(`${PAGE_PREVIEW_HEIGHT}px`);
diff --git a/src/components/app/AppMessage.tsx b/src/components/app/AppMessage.tsx
index 355dcbc189..3a0f73260c 100644
--- a/src/components/app/AppMessage.tsx
+++ b/src/components/app/AppMessage.tsx
@@ -235,6 +235,8 @@ function AppRow({ botId, botName, threadId, message, payload, pool, room }: {
message.text ? <div dir="auto" className={cn("line-clamp-6 whitespace-pre-wrap text-[13px] leading-[18px] text-ink-secondary", compact ? "px-4 pt-3" : bordered ? "px-4 pb-3" : "pb-2")}>{message.text}</div> : null
) : (
<div data-app-box className={cn("relative w-full", compact && "overflow-hidden", bordered && !compact && "border-t border-ink/[0.08]", point.pointing && "ring-2 ring-inset ring-accent/60")}
+ // The whole card opens the page, so the keyboard must not reach what the preview shows underneath it.
+ inert={(compact && Boolean(current) && !point.pointing) || undefined}
style={{ height: boxHeight }}>
{current ? (
<AppFrame