diff --git a/packages/orbit-components/src/Card/Card.stories.tsx b/packages/orbit-components/src/Card/Card.stories.tsx index 6a2f9feefb..03ae957130 100644 --- a/packages/orbit-components/src/Card/Card.stories.tsx +++ b/packages/orbit-components/src/Card/Card.stories.tsx @@ -18,6 +18,7 @@ type CardPropsAndCustomArgs = React.ComponentProps & { sectionTitle: string; sectionDescription: string; initialExpanded?: boolean; + onClick: () => void; }; const meta: Meta = { @@ -312,7 +313,7 @@ export const CardWithDefaultExpanded: Story = { }; export const CardWithMixedSections: Story = { - render: ({ sectionTitle, sectionDescription, ...args }) => ( + render: ({ sectionTitle, sectionDescription, onClick, ...args }) => ( Section Content + + Section Content with onClick + ), + args: { + onClick: action("onClick"), + }, + parameters: { controls: { - exclude: ["labelClose", "initialExpanded", "expanded"], + exclude: ["labelClose", "initialExpanded", "expanded", "onClick"], }, }, }; diff --git a/packages/orbit-components/src/Card/CardSection/index.tsx b/packages/orbit-components/src/Card/CardSection/index.tsx index e649b4880f..9b7fecb37e 100644 --- a/packages/orbit-components/src/Card/CardSection/index.tsx +++ b/packages/orbit-components/src/Card/CardSection/index.tsx @@ -8,8 +8,30 @@ import { ELEMENT_OPTIONS } from "../../Heading/consts"; import type { Props } from "./types"; import Header from "../components/Header"; import Expandable from "./components/Expandable"; -import handleKeyDown from "../../utils/handleKeyDown"; import Stack from "../../Stack"; +import handleKeyDown from "../../utils/handleKeyDown"; + +const ContentWrapper = ({ + onClick, + className, + children, +}: Pick & { className?: string }) => ( + // eslint-disable-next-line jsx-a11y/no-static-element-interactions +
+ {children} +
+); const Actions = ({ actions }) => ( @@ -58,26 +80,20 @@ export default function CardSection({ return ( // Needs to capture bubbled click events from the