Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { Checkbox } from ".";
|
||||
|
||||
describe("Checkbox accessibility wrapper", () => {
|
||||
it("keeps a hidden string label as the checkbox accessible name", () => {
|
||||
render(<Checkbox hideLabel label="Accept privacy policy" />);
|
||||
|
||||
expect(screen.getByRole("checkbox", { name: "Accept privacy policy" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("preserves an explicit accessible name", () => {
|
||||
render(<Checkbox hideLabel label="Privacy" aria-label="Accept privacy policy" />);
|
||||
|
||||
expect(screen.getByRole("checkbox", { name: "Accept privacy policy" })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+8
-2
@@ -1,5 +1,7 @@
|
||||
"use client";
|
||||
import { Checkbox as CheckboxComponent } from "./Checkbox";
|
||||
import React from "react";
|
||||
|
||||
import { Checkbox as CheckboxComponent, type CheckboxRootProps } from "./Checkbox";
|
||||
|
||||
/**
|
||||
* Add wrapper components and business logic here.
|
||||
@@ -7,4 +9,8 @@ import { Checkbox as CheckboxComponent } from "./Checkbox";
|
||||
* Learn more: https://docs.subframe.com/concepts/syncing-components#wrapping-components
|
||||
*/
|
||||
|
||||
export const Checkbox = CheckboxComponent;
|
||||
export const Checkbox = React.forwardRef<HTMLButtonElement, CheckboxRootProps>(function Checkbox(props, ref) {
|
||||
const accessibleLabel =
|
||||
props["aria-label"] ?? (props["aria-labelledby"] ? undefined : props.hideLabel && typeof props.label === "string" ? props.label : undefined);
|
||||
return <CheckboxComponent {...props} aria-label={accessibleLabel} ref={ref} />;
|
||||
});
|
||||
Reference in new issue
Block a user