TypeScript
fix(web): right-panel launcher letters work while a closed menu stays mounted (#18132)
macob3a13349505e
diff --git a/apps/web/src/components/RightPanelTabs.keyboard.browser.test.tsx b/apps/web/src/components/RightPanelTabs.keyboard.browser.test.tsxindex 38c14776408..adbe0d586b2 100644--- a/apps/web/src/components/RightPanelTabs.keyboard.browser.test.tsx+++ b/apps/web/src/components/RightPanelTabs.keyboard.browser.test.tsx@@ -137,6 +137,28 @@ describe("right panel new-tab shortcut", () => {},);+ it("opens Files while a closed popup remains mounted", async () => {+ await renderPanel();+ const popup = document.createElement("div");+ popup.dataset.slot = "menu-popup";+ popup.dataset.closed = "";+ container.append(popup);++ expect((await press("f")).defaultPrevented).toBe(true);+ expect(addFiles).toHaveBeenCalledOnce();+ });++ it("opens the add-surface menu while a closed popup remains mounted", async () => {+ await renderPanel();+ const popup = document.createElement("div");+ popup.dataset.slot = "menu-popup";+ popup.dataset.closed = "";+ container.append(popup);++ expect((await press("t", { metaKey: true })).defaultPrevented).toBe(true);+ expect(document.querySelector('[role="menu"]:not([data-closed])')).not.toBeNull();+ });+it("leaves the shortcut alone while the mounted panel is closed", async () => {await renderPanel({ open: false });expect((await press("t", { metaKey: true })).defaultPrevented).toBe(false);@@ -197,8 +219,14 @@ describe("right panel new-tab shortcut", () => {const dialog = document.createElement("div");dialog.dataset.slot = "dialog-popup";container.append(dialog);- expect((await press("t", { metaKey: true })).defaultPrevented).toBe(false);- expect(document.querySelector('[role="menu"]')).toBeNull();+ for (const state of ["data-open", "data-ending-style"]) {+ dialog.setAttribute(state, "");+ expect((await press("f")).defaultPrevented, state).toBe(false);+ expect(addFiles, state).not.toHaveBeenCalled();+ expect((await press("t", { metaKey: true })).defaultPrevented, state).toBe(false);+ expect(document.querySelector('[role="menu"]'), state).toBeNull();+ dialog.removeAttribute(state);+ }});it("supports arrow keys with an existing tab in sheet mode and clears the menu on close", async () => {diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsxindex c44de7b9bcb..5a705cbc6fc 100644--- a/apps/web/src/components/RightPanelTabs.tsx+++ b/apps/web/src/components/RightPanelTabs.tsx@@ -174,16 +174,19 @@ const SURFACE_DISABLED_REASONS = {device: "Devices are only available from a thread.",} as const;+// Closed keepMounted popups must stop blocking shortcuts once their exit transition ends.const LAUNCHER_SHORTCUT_BLOCKING_LAYERS = [- '[data-slot="dialog-popup"]',- '[data-slot="alert-dialog-popup"]',- '[data-slot="command-dialog-popup"]',- '[data-slot="menu-popup"]',- '[data-slot="select-popup"]',- '[data-slot="popover-popup"]',- '[data-slot="combobox-popup"]',- '[data-slot="autocomplete-popup"]',-].join(",");+ "dialog-popup",+ "alert-dialog-popup",+ "command-dialog-popup",+ "menu-popup",+ "select-popup",+ "popover-popup",+ "combobox-popup",+ "autocomplete-popup",+]+ .map((slot) => `[data-slot="${slot}"]:is([data-open],[data-ending-style])`)+ .join(",");const SURFACE_UNAVAILABLE_HINTS = {browser: "Only available in the desktop app.",