Skip to content

Commit 7e6b6bd

Browse files
committed
fix(web): remove gaps between permission options
1 parent 5211acf commit 7e6b6bd

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎apps/web/src/components/chat/ComposerFooterControls.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export function ComposerPermissionsSection(props: {
182182
onValueChange={(value: RuntimeMode) => {
183183
if (value !== props.runtimeMode) props.onRuntimeModeChange(value);
184184
}}
185-
className="flex gap-0.5 rounded-lg bg-input/40 p-0.5"
185+
className="flex rounded-lg bg-input/40 p-0.5"
186186
// Menus navigate with Up/Down only; the row reads horizontally, so Left/Right move too.
187187
onKeyDown={(event) => {
188188
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
@@ -211,7 +211,7 @@ export function ComposerPermissionsSection(props: {
211211
onPointerLeave={() => setPreviewMode(null)}
212212
onFocus={() => setPreviewMode(option.mode)}
213213
onBlur={() => setPreviewMode(null)}
214-
className="flex h-6 flex-1 cursor-pointer items-center justify-center rounded-md text-muted-foreground outline-none data-checked:bg-input/72 data-checked:text-foreground data-highlighted:text-foreground not-data-checked:data-highlighted:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"
214+
className="flex h-6 flex-1 cursor-pointer items-center justify-center text-muted-foreground outline-none first:rounded-l-md last:rounded-r-md data-checked:bg-input/72 data-checked:text-foreground data-highlighted:text-foreground not-data-checked:data-highlighted:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"
215215
>
216216
<OptionIcon aria-hidden="true" className="size-3.5" />
217217
</MenuPrimitive.RadioItem>

‎apps/web/src/components/chat/ComposerPermissionsSection.browser.test.tsx‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type ReactNode, useRef, useState } from "react";
33
import { expect, it, vi } from "vite-plus/test";
44
import { page, userEvent } from "vite-plus/test/browser";
55

6+
import "../../index.css";
67
import { render } from "../../../test/render";
78
import { ComposerHandleContext, type ComposerHandleRef } from "../../composerHandleContext";
89
import { Menu, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "../ui/menu";
@@ -87,6 +88,26 @@ it("marks the current mode as checked and closes on Escape", async () => {
8788
await expect.element(screen.getByRole("button", { name: "Effort" })).toHaveFocus();
8889
});
8990

91+
it("keeps the space between permission options clickable", async () => {
92+
await using screen = await render(<EffortMenu />, { router: false });
93+
await userEvent.click(screen.getByRole("button", { name: "Effort" }));
94+
const items = options.map((option) =>
95+
page.getByRole("menuitemradio", { name: option.label }).element(),
96+
);
97+
98+
for (let i = 0; i < items.length - 1; i++) {
99+
const left = items[i]!;
100+
const right = items[i + 1]!;
101+
const leftRect = left.getBoundingClientRect();
102+
const rightRect = right.getBoundingClientRect();
103+
expect(rightRect.left - leftRect.right).toBeLessThanOrEqual(0);
104+
for (const y of [leftRect.top + 1, leftRect.top + leftRect.height / 2]) {
105+
expect(left.contains(document.elementFromPoint(leftRect.right - 1.5, y))).toBe(true);
106+
expect(right.contains(document.elementFromPoint(rightRect.left + 1.5, y))).toBe(true);
107+
}
108+
}
109+
});
110+
90111
// The real composer menu focus rule (useComposerMenuProps), with a stub composer handle.
91112
function withComposer(children: ReactNode) {
92113
const handle = { focusAtEnd: vi.fn() };

0 commit comments

Comments
 (0)