Skip to content

Commit 74573fc

Browse files
fix(web): new project publish option tells screen readers whether it is on (#36090)
1 parent eb7e63a commit 74573fc

4 files changed

Lines changed: 44 additions & 3 deletions

File tree

‎apps/web/src/components/CommandPalette.composition.browser.test.tsx‎

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,32 @@ import { CommandPalette } from "./CommandPalette";
88
import { openCommandPalette } from "../commandPaletteBus";
99
import { primaryServerKeybindingsAtom } from "../state/server";
1010

11-
const scopes = vi.hoisted(() => ({ denied: undefined as string | undefined }));
12-
const setup = (deniedScope?: string) => {
11+
const scopes = vi.hoisted(() => ({
12+
denied: undefined as string | undefined,
13+
sourceControl: undefined as unknown,
14+
}));
15+
const setup = (deniedScope?: string, sourceControl?: unknown) => {
1316
scopes.denied = deniedScope;
17+
scopes.sourceControl = sourceControl;
18+
};
19+
const githubAvailable = {
20+
versionControlSystems: [],
21+
sourceControlProviders: [
22+
{
23+
kind: "github",
24+
label: "GitHub",
25+
status: "available",
26+
version: { _tag: "None" },
27+
installHint: "Install GitHub CLI",
28+
detail: { _tag: "None" },
29+
auth: {
30+
status: "authenticated",
31+
account: { _tag: "Some", value: "demo" },
32+
host: { _tag: "None" },
33+
detail: { _tag: "None" },
34+
},
35+
},
36+
],
1437
};
1538

1639
vi.mock("@effect/atom-react", async (original) => ({
@@ -101,7 +124,7 @@ vi.mock("../state/filesystem", async (original) => ({
101124
}));
102125
vi.mock("../state/query", async (original) => ({
103126
...(await original<typeof import("../state/query")>()),
104-
useEnvironmentQuery: () => ({ data: undefined, isLoading: false }),
127+
useEnvironmentQuery: () => ({ data: scopes.sourceControl, isLoading: false }),
105128
}));
106129
vi.mock("./settings/useAvailableSettingsSearchItems", () => ({
107130
useAvailableSettingsSearchItems: () => [],
@@ -208,3 +231,15 @@ it.each([
208231
await userEvent.keyboard("{Tab}");
209232
await expect.element(submit).toHaveFocus();
210233
});
234+
235+
it("tells screen readers whether a new project will be published", async () => {
236+
setup(undefined, githubAvailable);
237+
await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
238+
await act(() => openCommandPalette({ open: "add-project" }));
239+
await page.getByText("New project", { exact: true }).click();
240+
await page.getByRole("combobox").fill("demo-project");
241+
const option = page.getByRole("option", { name: /Create private repository/ });
242+
await expect.element(option).toHaveAttribute("aria-checked", "false");
243+
await option.click();
244+
await expect.element(option).toHaveAttribute("aria-checked", "true");
245+
});

‎apps/web/src/components/CommandPalette.logic.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ export interface CommandPaletteActionItem extends CommandPaletteItem {
213213
readonly run: () => Promise<void>;
214214
/** A pin toggle on the row, also reached with the pin shortcut while the row is highlighted. */
215215
readonly pin?: CommandPaletteItemPin;
216+
/** Set on toggle rows; exposed to assistive technology as `aria-checked`. */
217+
readonly checked?: boolean;
216218
}
217219

218220
export interface CommandPaletteItemPin {

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,7 @@ function OpenCommandPaletteDialog(props: {
24272427
),
24282428
...(isCreatingNewProject ? { disabled: true } : {}),
24292429
keepOpen: true,
2430+
checked: newProjectPublishes,
24302431
run: async () => {
24312432
setNewProjectPublishes((publishes) => !publishes);
24322433
},

‎apps/web/src/components/CommandPaletteResults.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ function CommandPaletteResultRow(props: {
250250
{...(props.index === undefined ? {} : { index: props.index })}
251251
value={props.item.value}
252252
active={props.isActive}
253+
{...(props.item.kind === "action" && props.item.checked !== undefined
254+
? { "aria-checked": props.item.checked }
255+
: {})}
253256
onPointerDown={(event) => {
254257
if (props.item.threadRef) {
255258
startPaletteThreadDrag(

0 commit comments

Comments
 (0)