Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-fieldsets-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/kumo": patch
---

Reset the native fieldset padding in radio and checkbox groups.
16 changes: 16 additions & 0 deletions packages/kumo/src/components/checkbox/checkbox.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { describe, expect, it } from "vite-plus/test";
import { render, screen } from "@testing-library/react";
import { Checkbox } from "./checkbox";

describe("Checkbox.Group", () => {
it("resets inherited fieldset padding", () => {
const { container } = render(
<Checkbox.Group legend="Preferences">
<Checkbox.Item label="Email notifications" value="email" />
</Checkbox.Group>,
);

expect(screen.getByText("Preferences")).toBeTruthy();
expect(container.querySelector("fieldset")?.className).toContain("p-0");
});
});
2 changes: 1 addition & 1 deletion packages/kumo/src/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function CheckboxGroup({
allValues={allValues}
disabled={disabled}
>
<Fieldset.Root className={cn("flex flex-col gap-4", className)}>
<Fieldset.Root className={cn("flex flex-col gap-4 p-0", className)}>
{legend && (
<Fieldset.Legend className="text-base font-medium text-kumo-default">
{legend}
Expand Down
3 changes: 2 additions & 1 deletion packages/kumo/src/components/radio/radio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

describe("Radio", () => {
it("renders a radio group with legend and items", () => {
render(
const { container } = render(
<Radio.Group legend="Choose option" defaultValue="a">
<Radio.Item label="Option A" value="a" />
<Radio.Item label="Option B" value="b" />
Expand All @@ -18,6 +18,7 @@ describe("Radio", () => {
expect(screen.getByText("Choose option")).toBeTruthy();
expect(screen.getByText("Option A")).toBeTruthy();
expect(screen.getByText("Option B")).toBeTruthy();
expect(container.querySelector("fieldset")?.className).toContain("p-0");
});

it("renders card items with description", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kumo/src/components/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ function RadioGroup<Value = string>({
>
<Fieldset.Root
disabled={disabled}
className={cn("flex flex-col gap-4", className)}
className={cn("flex flex-col gap-4 p-0", className)}
>
{legend && (
<Fieldset.Legend className="text-base font-medium text-kumo-default">
Expand Down
Loading