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
3 changes: 3 additions & 0 deletions packages/react/src/patterns/OneDataCollection/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export type SecondaryActionItem = Pick<
disabled: boolean
loading: boolean
}) => string | undefined
/** A count shown to the right of the label, e.g. how many items the action
* concerns. Ignored while the action is collapsed into the overflow menu. */
counterValue?: number
}

export type SecondaryActionGroup = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const CollectionActions = ({
variant="outline"
hideLabel={action.hideLabelWhenExpanded}
label={action.label}
counterValue={action.counterValue}
disabled={action.disabled}
loading={action.loading}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,27 @@ describe("CollectionActions", () => {
expect(screen.getByText("Export")).toBeInTheDocument()
})

it("forwards counterValue to the secondary action button", () => {
render(
<CollectionActions
secondaryActions={[
{
label: "To review",
icon: mockIcon,
onClick: vi.fn(),
counterValue: 3,
},
]}
/>
)

expect(screen.getByText("To review")).toBeInTheDocument()
expect(screen.getByTestId("f0-button")).toHaveAttribute(
"counterValue",
"3"
)
})

it("renders secondary action without Tooltip when tooltip is not provided", () => {
render(
<CollectionActions
Expand Down
Loading