Repository navigation
feat(accordion): support custom buttons in simple accordion - #8317
kaitlyn-owen wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Custom native button triggers omit type="button", so toggling the accordion inside a form can submit it or trigger validation; the props need updating and a regression test is needed.
1 open issue
What changed in this PR
Adds custom trigger rendering to Carbon’s simple Accordion through renderButton, while retaining the tertiary Button as the default.
Changes:
- Adds the renderer callback and a unit test for custom-trigger activation.
- Adds a subtle Button story and updates the generated Accordion reference.
- Adds description and social-sharing metadata to Storybook.
| File | Description |
|---|---|
src/components/accordion/accordion.test.tsx |
Tests custom-trigger rendering and click handling. |
src/components/accordion/accordion.stories.tsx |
Demonstrates a subtle Button trigger. |
src/components/accordion/accordion.component.tsx |
Adds renderButton and its supplied props. |
skills/carbon-react/components/accordion.md |
Documents the new prop and example. |
.storybook/manager-head.html |
Adds page and social-sharing metadata; normalizes formatting. |
Review effort: Balanced
d59112e to
66b24f8
Compare
66b24f8 to
6f18099
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The custom trigger’s required prop-forwarding contract remains undocumented, and browser coverage is missing for keyboard activation, ARIA relationships, panel visibility, and Space-key scroll prevention.
2 open issues
1 resolved since last review
Review effort: Balanced
adds support for custom and subtle buttons in the simple Accordion variant using renderButton prop.
6f18099 to
3295338
Compare
| import Button from "../button/__next__"; | ||
| import useMediaQuery from "../../hooks/useMediaQuery"; | ||
|
|
||
| export interface RenderButtonProps { |
There was a problem hiding this comment.
nitpick/suggestion: renderButton exposes RenderButtonProps as part of the public Accordion API, but the type is not re-exported. This means consumers can use inline callbacks, but cannot import the type to annotate a reusable renderer without duplicating or inferring its shape.
If we think we need to do this (we'll see what a second reviewer says), we could potentially export RenderButtonProps alongside AccordionProps. I believe we've done the same thing in ActionPopover if you need a template to go off.
There was a problem hiding this comment.
Looks like ActionPopover exports the RenderButtonProps so I agree we should probably do the same here
| }, | ||
| }; | ||
|
|
||
| export const SubtleVariant: Story = { |
There was a problem hiding this comment.
suggestion: Aware that the intention is to mainly support subtle buttons, but we could make the story name a bit more descriptive of the prop itself:
| export const SubtleVariant: Story = { | |
| export const CustomTriggerButton: Story = { |
I think it would also be good to add this story to the mdx file with a description of how to use this prop and any restrictions (only works on simple variant, etc), similar to how we've done in ActionPopover.


Proposed behaviour
The simple Accordion supports a custom button through the new
renderButtonprop, allowing consumers to use options such as a subtle button. WhenrenderButtonis not provided, the existingtertiarybutton remains the default.Current behaviour
The simple Accordion uses the
tertiarybutton and does not support providing a custom button.Checklist
d.tsfile added or updated if requiredQA
Additional context
Testing instructions