Skip to content
Open
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
16 changes: 16 additions & 0 deletions packages/elements/__tests__/confirmation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,22 @@ describe("confirmationActions", () => {
const actionsContainer = screen.getByText("Accept").parentElement;
expect(actionsContainer).toHaveClass("custom-class");
});

it("merges custom className on actions without dropping compact sizing", () => {
render(
<Confirmation approval={{ id: "test-id" }} state="approval-requested">
<ConfirmationActions>
<ConfirmationAction className="text-destructive" variant="outline">
Reject
</ConfirmationAction>
<ConfirmationAction variant="default">Accept</ConfirmationAction>
</ConfirmationActions>
</Confirmation>
);
const reject = screen.getByText("Reject");
expect(reject).toHaveClass("text-destructive", "h-8", "px-3", "text-sm");
expect(screen.getByText("Accept")).toHaveClass("h-8", "px-3", "text-sm");
});
});

describe("confirmationAccepted", () => {
Expand Down
16 changes: 12 additions & 4 deletions packages/elements/src/confirmation.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use client";

import type { ToolUIPart } from "ai";
import type { ComponentProps, ReactNode } from "react";

import { Alert, AlertDescription } from "@repo/shadcn-ui/components/ui/alert";
import { Button } from "@repo/shadcn-ui/components/ui/button";
import { cn } from "@repo/shadcn-ui/lib/utils";
import type { ToolUIPart } from "ai";
import type { ComponentProps, ReactNode } from "react";
import { createContext, useContext, useMemo } from "react";

type ToolUIPartApproval =
Expand Down Expand Up @@ -164,6 +165,13 @@ export const ConfirmationActions = ({

export type ConfirmationActionProps = ComponentProps<typeof Button>;

export const ConfirmationAction = (props: ConfirmationActionProps) => (
<Button className="h-8 px-3 text-sm" type="button" {...props} />
export const ConfirmationAction = ({
className,
...props
}: ConfirmationActionProps) => (
<Button
className={cn("h-8 px-3 text-sm", className)}
type="button"
{...props}
/>
);