Skip to content

[Bug]: Two quick arrow presses advance only one sheet in an Excel preview #41007

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Open an Excel workbook with at least three visible sheets in the Files panel.
  2. Focus the first sheet tab.
  3. Press Right Arrow twice quickly, before the second sheet finishes opening.

Expected behavior

The third sheet opens.

Actual behavior

The preview stops on the second sheet.

after two right arrows

failure

Impact

Minor bug or occasional failure. Keyboard users can miss a sheet whenever they press an arrow key again before the previous switch completes.

Version or commit

main at 6972026121. The cause is at apps/web/src/components/files/office/Spreadsheet.tsx:129.

Environment

Linux x64 boat.dev default machine, a fresh checkout.

Logs or stack traces

Actuals
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/scripts/scenarios/xlsx-rapid-arrow-keys-advance-both-sheets.e2e.ts b/scripts/scenarios/xlsx-rapid-arrow-keys-advance-both-sheets.e2e.ts
new file mode 100644
index 0000000000..ee30dd352d
--- /dev/null
+++ b/scripts/scenarios/xlsx-rapid-arrow-keys-advance-both-sheets.e2e.ts
@@ -0,0 +1,72 @@
+/// <reference lib="dom" />
+import { expect } from "e2e";
+import JSZip from "jszip";
+
+import { test, WEB } from "./t3.ts";
+
+const SHEETS = ["Overview", "Actuals", "Forecast"];
+const RELATIONSHIPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
+
+async function workbook() {
+  const archive = new JSZip();
+  const sheets = SHEETS.map(
+    (name, index) => `<sheet name="${name}" sheetId="${index + 1}" r:id="sheet${index + 1}"/>`,
+  ).join("");
+  archive.file(
+    "xl/workbook.xml",
+    `<workbook xmlns:r="${RELATIONSHIPS}"><sheets>${sheets}</sheets></workbook>`,
+  );
+  const relationships = SHEETS.map(
+    (_, index) =>
+      `<Relationship Id="sheet${index + 1}" Type="${RELATIONSHIPS}/worksheet" Target="worksheets/sheet${index + 1}.xml"/>`,
+  ).join("");
+  archive.file("xl/_rels/workbook.xml.rels", `<Relationships>${relationships}</Relationships>`);
+  for (const [index] of SHEETS.entries())
+    archive.file(
+      `xl/worksheets/sheet${index + 1}.xml`,
+      `<worksheet><sheetData><row r="1"><c r="A1"><v>${index + 1}</v></c></row></sheetData></worksheet>`,
+    );
+  return archive.generateAsync({ type: "uint8array" });
+}
+
+test(
+  "Two rapid right arrows advance two tabs in an Excel preview",
+  WEB,
+  async ({ t3, app, screen, browser }) => {
+    const project = await t3.project("demo", { "budget.xlsx": await workbook() });
+    const thread = await t3.thread({ project, title: "Review budget", messages: ["Start"] });
+    await t3.open(thread);
+    await screen.getByText("fixture turn complete", { exact: false }).waitFor();
+
+    await browser.keyboard.press("Control+p");
+    await screen.getByPlaceholder("Search files…").fill("budget.xlsx");
+    await screen.getByRole("option", "budget.xlsx", { exact: false }).tap();
+    await screen.getByRole("tab", "Overview").waitFor({ timeout: 120_000 });
+
+    // Deliver both keystrokes before the worker can report the first sheet switch.
+    await browser.evaluate(() => {
+      const first = document.querySelector<HTMLButtonElement>(
+        '[role="tablist"] [role="tab"][aria-selected="true"]',
+      )!;
+      first.focus();
+      for (let press = 0; press < 2; press++)
+        document.activeElement?.dispatchEvent(
+          new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true, cancelable: true }),
+        );
+      return null;
+    });
+    await screen.getByRole("grid", /Actuals|Forecast/).waitFor();
+    await app.screenshot("after-two-right-arrows");
+    await expect
+      .poll(() =>
+        browser.evaluate(
+          () =>
+            document
+              .querySelector('[role="tablist"]')
+              ?.parentElement?.querySelector('[role="grid"]')
+              ?.getAttribute("aria-label") ?? null,
+        ),
+      )
+      .toBe("Forecast");
+  },
+);
pnpm scenarios:prove scripts/scenarios/xlsx-rapid-arrow-keys-advance-both-sheets.e2e.ts --base main

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions