From 28c36b8a5b87e26db8707bf7b79aacf271a9c6c8 Mon Sep 17 00:00:00 2001 From: Jerel John Velarde Date: Mon, 31 Aug 2026 04:12:05 -0700 Subject: [PATCH] Let a button drawn as a link answer the keyboard like a button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Six controls in the app are buttons that navigate: "New skill", "New agent", the sidebar's new-channel control, the two empty-state returns, and PageShell's back button, which is five routes in every state each of them has. All six draw a router Link through `render`. Base UI defaults `nativeButton` to true, so every one of them was told to expect a native ); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("BUTTON"); + expect(element.getAttribute("type")).toBe("button"); + expect(element.getAttribute("role")).toBeNull(); +}); + +test("a button drawn as a link takes button semantics rather than `type`", () => { + const { complaints, element } = drawing( + , + ); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("A"); + expect(element.getAttribute("role")).toBe("button"); + expect(element.getAttribute("type")).toBeNull(); +}); + +/** + * The shape `PageShell`'s back button and the sidebar's links use: a function, because a router + * `Link` takes its own props alongside the ones Base UI merges in. + */ +test("a button drawn as a link through the function form does the same", () => { + const { complaints, element } = drawing( + , + ); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("A"); + expect(element.getAttribute("role")).toBe("button"); +}); + +/** + * `render` that draws a real button is the case the default cannot see, so a call site says so — + * `combobox.tsx` is the one that does. + */ +test("a call site drawing a real button can say so", () => { + const { complaints, element } = drawing( + , + ); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("BUTTON"); + expect(element.getAttribute("role")).toBeNull(); +});