Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(ui): name the slider's range input instead of its group (MUL-9219) (#10568)

Jiayuan Zhangc75012fd69c3
diff --git a/packages/ui/components/ui/slider.tsx b/packages/ui/components/ui/slider.tsx
index 28b7f62252..8b602b64b2 100644
--- a/packages/ui/components/ui/slider.tsx
+++ b/packages/ui/components/ui/slider.tsx
@@ -11,6 +11,7 @@ function Slider({
value,
min = 0,
max = 100,
+ "aria-label": ariaLabel,
...props
}: SliderPrimitive.Root.Props) {
const _values = React.useMemo(() => {
@@ -44,6 +45,8 @@ function Slider({
<SliderPrimitive.Thumb
data-slot="slider-thumb"
key={index}
+ // The focusable range input lives in the thumb; a label on Root only names the group.
+ aria-label={ariaLabel}
className="relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"
/>
))}
diff --git a/packages/views/common/avatar-crop-dialog.test.tsx b/packages/views/common/avatar-crop-dialog.test.tsx
index 1c2040a2a8..e7f27e6dc8 100644
--- a/packages/views/common/avatar-crop-dialog.test.tsx
+++ b/packages/views/common/avatar-crop-dialog.test.tsx
@@ -70,7 +70,7 @@ describe("AvatarCropDialog encoding", () => {
expect(screen.getByRole("button", { name })).toBeDisabled();
}
expect(screen.queryByRole("button", { name: "Close" })).not.toBeInTheDocument();
- expect(screen.getByRole("slider")).toBeDisabled();
+ expect(screen.getByRole("slider", { name: "Zoom" })).toBeDisabled();
expect(apply).toHaveAttribute("aria-busy", "true");
expect(screen.queryByText("Uploading…")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
diff --git a/packages/views/settings/components/appearance-tab.test.tsx b/packages/views/settings/components/appearance-tab.test.tsx
index 7743b26f1f..1839d22cfd 100644
--- a/packages/views/settings/components/appearance-tab.test.tsx
+++ b/packages/views/settings/components/appearance-tab.test.tsx
@@ -163,17 +163,21 @@ describe("AppearanceTab", () => {
});
describe("content font size", () => {
- const sizeSliders = () =>
- screen.getAllByLabelText("Font size").map((root) => within(root).getByRole("slider", { hidden: true }));
+ const sizeSliders = () => screen.getAllByRole("slider", { name: "Font size" });
const follow = () => screen.getByRole("switch", { name: "Match interface size" });
const press = async (slider: HTMLElement, key: string) => {
act(() => slider.focus());
await userEvent.setup().keyboard(key);
};
+ // Base UI keeps edge-aligned thumbs visibility: hidden until a microtask has measured them.
+ const renderTab = async () => {
+ render(<AppearanceTab />, { wrapper: Wrapper });
+ await screen.findAllByRole("slider", { name: "Font size" });
+ };
- it("follows the interface by default, with the same slider", () => {
+ it("follows the interface by default, with the same slider", async () => {
useAppearanceStore.setState({ fontSize: 15 });
- render(<AppearanceTab />, { wrapper: Wrapper });
+ await renderTab();
const [, content] = sizeSliders();
expect(content).toHaveValue("15");
@@ -183,7 +187,7 @@ describe("AppearanceTab", () => {
it("keeps a size equal to the interface independent of later interface changes", async () => {
useAppearanceStore.setState({ fontSize: 14, contentSize: 15 });
- render(<AppearanceTab />, { wrapper: Wrapper });
+ await renderTab();
expect(follow()).not.toBeChecked();
await press(sizeSliders()[1]!, "{ArrowLeft}");
@@ -198,7 +202,7 @@ describe("AppearanceTab", () => {
it("pins the current size when following is turned off, and follows again only when turned on", async () => {
const user = userEvent.setup();
useAppearanceStore.setState({ fontSize: 13 });
- render(<AppearanceTab />, { wrapper: Wrapper });
+ await renderTab();
await user.click(follow());
expect(state().contentSize).toBe(13);
@@ -456,6 +460,7 @@ describe("AppearanceTab", () => {
expect(screen.getByText("The paper itself.")).toBeInTheDocument();
expect(screen.getByRole("heading", { name: "Type" })).toBeInTheDocument();
expect(screen.getByLabelText("Paper (Dark)")).toHaveValue("#1d1b16");
+ expect(await screen.findByRole("slider", { name: "Width" })).toHaveValue("46");
expect(screen.getByText("46rem")).toBeInTheDocument();
const font = () => screen.getByRole("textbox", { name: "Heading font" });