diff --git a/src/components/common/Interactive.tsx b/src/components/common/Interactive.tsx index 0c05d691..5b0dc47a 100644 --- a/src/components/common/Interactive.tsx +++ b/src/components/common/Interactive.tsx @@ -54,10 +54,9 @@ const isInvalid = (event: MouseEvent | TouchEvent, hasTouch: boolean): boolean = return hasTouch && !isTouch(event); }; -interface Props { +interface Props extends React.HTMLAttributes { onMove: (interaction: Interaction) => void; onKey: (offset: Interaction) => void; - children: React.ReactNode; } const InteractiveBase = ({ onMove, onKey, ...rest }: Props) => { @@ -143,7 +142,6 @@ const InteractiveBase = ({ onMove, onKey, ...rest }: Props) => { return (
{ onKeyDown={handleKeyDown} tabIndex={0} role="slider" + {...rest} /> ); }; diff --git a/src/components/common/Saturation.tsx b/src/components/common/Saturation.tsx index a197d569..9557e6c5 100644 --- a/src/components/common/Saturation.tsx +++ b/src/components/common/Saturation.tsx @@ -33,19 +33,25 @@ const SaturationBase = ({ hsva, onChange }: Props) => { return (
- - - +
+
+ + + +
+
); }; diff --git a/tests/__snapshots__/components.test.js.snap b/tests/__snapshots__/components.test.js.snap index 4c848835..e1cfd687 100644 --- a/tests/__snapshots__/components.test.js.snap +++ b/tests/__snapshots__/components.test.js.snap @@ -11,20 +11,33 @@ exports[`Accepts any valid \`div\` attributes 1`] = ` style="background-color: rgb(255, 0, 0);" >
+ aria-colcount="100" + aria-colindex="0" + aria-label="Saturation 0%" + class="react-colorful__interactive" + role="gridcell" + tabindex="0" + > +
+
+
+
@@ -72,20 +85,33 @@ exports[`Renders proper alpha color picker markup 1`] = ` style="background-color: rgb(255, 0, 0);" >
+ aria-colcount="100" + aria-colindex="100" + aria-label="Saturation 100%" + class="react-colorful__interactive" + role="gridcell" + tabindex="0" + > +
+
+
+
@@ -151,20 +177,33 @@ exports[`Renders proper color picker markup 1`] = ` style="background-color: rgb(255, 0, 0);" >
+ aria-colcount="100" + aria-colindex="100" + aria-label="Saturation 100%" + class="react-colorful__interactive" + role="gridcell" + tabindex="0" + > +
+
+
+
@@ -203,20 +242,33 @@ exports[`Works with no props 1`] = ` style="background-color: rgb(255, 0, 0);" >
+ aria-colcount="100" + aria-colindex="0" + aria-label="Saturation 0%" + class="react-colorful__interactive" + role="gridcell" + tabindex="0" + > +
+
+
+
diff --git a/tests/components.test.js b/tests/components.test.js index 86be3bdd..f04d5b48 100644 --- a/tests/components.test.js +++ b/tests/components.test.js @@ -323,13 +323,20 @@ it("Sets proper `aria-valuetext` attribute value", async () => { const saturation = result.container.querySelector( ".react-colorful__saturation .react-colorful__interactive" ); + const brightness = saturation.parentElement; - expect(saturation.getAttribute("aria-valuetext")).toBe("Saturation 0%, Brightness 0%"); + expect(saturation.getAttribute("aria-label")).toBe("Saturation 0%"); + expect(saturation.getAttribute("aria-colindex")).toBe("0"); + expect(brightness.getAttribute("aria-label")).toBe("Brightness 0%"); + expect(brightness.getAttribute("aria-rowindex")).toBe("0"); fireEvent(saturation, new FakeMouseEvent("mousedown", { pageX: 0, pageY: 0 })); fireEvent(saturation, new FakeMouseEvent("mousemove", { pageX: 500, pageY: 0 })); // '#ff0000' - expect(saturation.getAttribute("aria-valuetext")).toBe("Saturation 100%, Brightness 100%"); + expect(saturation.getAttribute("aria-label")).toBe("Saturation 100%"); + expect(saturation.getAttribute("aria-colindex")).toBe("100"); + expect(brightness.getAttribute("aria-label")).toBe("Brightness 100%"); + expect(brightness.getAttribute("aria-rowindex")).toBe("100"); }); it("Accepts any valid `div` attributes", () => {