Open the Share access menu above the dialog so both options can be picked.

The listbox was clipped inside the sheet, sat at 24px, and ignored arrow keys, so Anyone with the link could not be chosen by mouse or touch.
This commit is contained in:
adilallo committed 2026-11-21 11:41:05 -07:00
1 parent 2dfc365dbd
commit 3a264ac2df
9 files changed
+264 -56

No files matched your search

+34
View File
@@ -1,6 +1,10 @@
import "@testing-library/jest-dom/vitest";
import React from "react";
import { describe, expect, it, vi } from "vitest";
import userEvent from "@testing-library/user-event";
import SelectInput from "../../app/components/controls/SelectInput";
import { componentTestSuite } from "../utils/componentTestSuite";
import { renderWithProviders, screen } from "../utils/test-utils";
type SelectInputProps = React.ComponentProps<typeof SelectInput>;
@@ -31,3 +35,33 @@ componentTestSuite<SelectInputProps>({
errorProps: { error: true },
},
});
describe("SelectInput listbox keyboard", () => {
it("moves between options with arrows and picks with Enter", async () => {
const onChange = vi.fn();
const user = userEvent.setup();
renderWithProviders(
<SelectInput
labelText="Who can read"
showLabel
value="option1"
onChange={onChange}
options={[
{ value: "option1", label: "Option 1" },
{ value: "option2", label: "Option 2" },
]}
/>,
);
const trigger = screen.getByRole("button", { name: /Who can read/i });
trigger.focus();
await user.keyboard("{ArrowDown}");
expect(await screen.findByRole("option", { name: "Option 1" })).toBeVisible();
expect(screen.getByRole("option", { name: "Option 2" })).toBeVisible();
await user.keyboard("{ArrowDown}{Enter}");
expect(onChange).toHaveBeenCalledWith({
target: { value: "option2", text: "Option 2" },
});
expect(screen.queryByRole("listbox")).not.toBeInTheDocument();
});
});
+22
View File
@@ -201,6 +201,28 @@ describe("Share modal", () => {
).toBeInTheDocument();
});
it("shows both access options and picks one with arrow keys", async () => {
const user = userEvent.setup();
openShare();
const trigger = screen.getByRole("button", {
name: /Only people you invite/i,
});
trigger.focus();
await user.keyboard("{ArrowDown}");
const inviteOnly = await screen.findByRole("option", {
name: "Only people you invite",
});
const anyone = screen.getByRole("option", { name: "Anyone with the link" });
expect(inviteOnly).toBeVisible();
expect(anyone).toBeVisible();
await user.keyboard("{ArrowDown}{Enter}");
expect(
screen.getByText(
"Anyone with the link can read it without logging in and pass it on. Check with your community first.",
),
).toBeInTheDocument();
});
it("calls onClose when Done is clicked", async () => {
const user = userEvent.setup();
const onClose = vi.fn();