fix(webui): make sidebar actions discoverable on touch devices
This commit is contained in:
1 parent
948ce38246
commit
6b24ed80ad
5 files changed
+75
-5
No files matched your search
@@ -111,6 +111,11 @@ workspace selection, and linked automations. Use a new topic when you want a
|
||||
separate context; use fork when you want to continue from an existing point
|
||||
without changing the original thread.
|
||||
|
||||
On touch devices, sidebar action buttons stay visible with larger touch areas
|
||||
for topics, conversation groups, panes, and projects. Tap a title to select it
|
||||
or the adjacent action button for its menu. Desktop actions still appear on
|
||||
hover or keyboard focus.
|
||||
|
||||
Drag a topic within its current sidebar group to keep frequently used work in
|
||||
your preferred order. Drag a topic from the sidebar into the composer when you
|
||||
want to reference it in the next message instead of switching to it.
|
||||
|
||||
@@ -1048,7 +1048,7 @@ export const ChatList = memo(function ChatList({
|
||||
>
|
||||
<DropdownMenuTrigger
|
||||
className={cn(
|
||||
"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",
|
||||
"sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",
|
||||
"media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover:opacity-100",
|
||||
"focus-visible:opacity-100 data-[state=open]:opacity-100",
|
||||
)}
|
||||
@@ -1295,7 +1295,7 @@ function WorkbenchTabHeader({
|
||||
>
|
||||
<DropdownMenuTrigger
|
||||
className={cn(
|
||||
"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md",
|
||||
"sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md",
|
||||
"text-sidebar-muted-foreground opacity-0 transition-opacity",
|
||||
"media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover/tab:opacity-100",
|
||||
"focus-visible:opacity-100 data-[state=open]:opacity-100",
|
||||
@@ -1491,7 +1491,7 @@ function ActivePaneRows({
|
||||
>
|
||||
<DropdownMenuTrigger
|
||||
className={cn(
|
||||
"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",
|
||||
"sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",
|
||||
"media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover/pane:opacity-100",
|
||||
"focus-visible:opacity-100 data-[state=open]:opacity-100",
|
||||
)}
|
||||
@@ -1787,7 +1787,7 @@ function ProjectGroupHeader({
|
||||
>
|
||||
<DropdownMenuTrigger
|
||||
className={cn(
|
||||
"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",
|
||||
"sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",
|
||||
"media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover:opacity-100 focus-visible:opacity-100",
|
||||
"data-[state=open]:opacity-100",
|
||||
)}
|
||||
|
||||
@@ -909,6 +909,11 @@
|
||||
.touch-target.preview-tab-close {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Touch users cannot hover a sidebar row to discover its actions. */
|
||||
.sidebar-action-trigger {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* On phones, actions follow the message instead of taking a separate gutter. */
|
||||
|
||||
@@ -99,6 +99,28 @@ describe("ChatList", () => {
|
||||
expect(conversation.querySelector("[data-sidebar-selection-track]")).toBeNull();
|
||||
});
|
||||
|
||||
it("opens topic actions with a dedicated touch target without selecting the topic", async () => {
|
||||
const onSelect = vi.fn();
|
||||
const onRequestRename = vi.fn();
|
||||
render(<ChatList
|
||||
sessions={[session({ chatId: "review", title: "Review the patch" })]}
|
||||
activeKey={null}
|
||||
onSelect={onSelect}
|
||||
onRequestDelete={vi.fn()}
|
||||
onTogglePin={vi.fn()}
|
||||
onRequestRename={onRequestRename}
|
||||
onToggleArchive={vi.fn()}
|
||||
/>);
|
||||
const trigger = screen.getByRole("button", { name: "Topic actions for Review the patch" });
|
||||
expect(trigger).toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");
|
||||
fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false });
|
||||
fireEvent.click(await screen.findByRole("menuitem", { name: "Rename" }));
|
||||
expect(onRequestRename).toHaveBeenCalledWith("websocket:review", "Review the patch");
|
||||
expect(onSelect).not.toHaveBeenCalled();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Review the patch" }));
|
||||
expect(onSelect).toHaveBeenCalledWith("websocket:review");
|
||||
});
|
||||
|
||||
it("marks a conversation that needs recovery attention with a warning indicator", () => {
|
||||
render(
|
||||
<ChatList
|
||||
@@ -689,7 +711,10 @@ describe("ChatList", () => {
|
||||
.toHaveAttribute("data-active-id", "websocket:root");
|
||||
expect(screen.getByRole("button", {
|
||||
name: "Research pane pane actions",
|
||||
})).toHaveClass("opacity-0");
|
||||
})).toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");
|
||||
expect(screen.getByRole("button", {
|
||||
name: "Topic actions for Root topic",
|
||||
})).toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");
|
||||
expect(within(tabGroup).getByRole("button", { name: "Root topic" }))
|
||||
.not.toHaveAttribute("aria-current");
|
||||
expect(tabGroup).not.toHaveTextContent("2/4");
|
||||
@@ -754,6 +779,8 @@ describe("ChatList", () => {
|
||||
fireEvent.click(await screen.findByRole("menuitem", { name: "Select" }));
|
||||
|
||||
expect(screen.getByText("1 selected")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Root topic pane actions" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Topic actions for Root topic" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Group: Root topic" }));
|
||||
expect(screen.getByRole("button", { name: "Group: Root topic" }))
|
||||
.toHaveAttribute("aria-pressed", "true");
|
||||
@@ -1189,6 +1216,8 @@ describe("ChatList", () => {
|
||||
);
|
||||
|
||||
const projectSection = screen.getByRole("region", { name: "Photos" });
|
||||
expect(within(projectSection).getByRole("button", { name: "Topic actions for Photos" }))
|
||||
.toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");
|
||||
fireEvent.click(within(projectSection).getByRole("button", { name: "Photos" }));
|
||||
|
||||
expect(onToggleGroup).toHaveBeenCalledWith("project:/Users/me/nanobot");
|
||||
|
||||
@@ -7,6 +7,37 @@ import loadConfig from "tailwindcss/loadConfig";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("sidebar touch hover isolation", () => {
|
||||
it("shows sidebar actions with roomy targets only for coarse pointers", async () => {
|
||||
const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));
|
||||
const source = readFileSync(resolve(process.cwd(), "src/globals.css"), "utf8");
|
||||
const result = await postcss([tailwindcss({ ...config, content: [{
|
||||
raw: 'class="sidebar-action-trigger touch-target opacity-0 h-6 w-6"',
|
||||
}] })]).process(source, { from: undefined });
|
||||
let hiddenIndex = -1;
|
||||
let visibleIndex = -1;
|
||||
let index = 0;
|
||||
let touchTarget = false;
|
||||
result.root.walkRules((rule) => {
|
||||
index++;
|
||||
if (rule.selector === ".opacity-0") hiddenIndex = index;
|
||||
if (rule.selector === ".sidebar-action-trigger") {
|
||||
visibleIndex = index;
|
||||
expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });
|
||||
expect(rule.nodes).toContainEqual(expect.objectContaining({ prop: "opacity", value: "1" }));
|
||||
}
|
||||
if (rule.selector === ".touch-target") {
|
||||
touchTarget = true;
|
||||
expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });
|
||||
for (const prop of ["min-width", "min-height"]) {
|
||||
expect(rule.nodes).toContainEqual(expect.objectContaining({ prop, value: "2.75rem" }));
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(hiddenIndex).toBeGreaterThan(0);
|
||||
expect(visibleIndex).toBeGreaterThan(hiddenIndex);
|
||||
expect(touchTarget).toBe(true);
|
||||
});
|
||||
|
||||
it("gates ordinary and named-group hover CSS without gating keyboard focus", async () => {
|
||||
const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));
|
||||
const source = readFileSync(
|
||||
|
||||
Reference in new issue
Block a user