Skip to content

feat(accordion): support custom buttons in simple accordion - #8317

Open
kaitlyn-owen wants to merge 1 commit into
masterfrom
FE-7867
Open

kaitlyn-owen wants to merge 1 commit into
masterfrom
FE-7867

Conversation

@kaitlyn-owen

Copy link
Copy Markdown
Contributor

Proposed behaviour

The simple Accordion supports a custom button through the new renderButton prop, allowing consumers to use options such as a subtle button. When renderButton is not provided, the existing tertiary button remains the default.

Current behaviour

The simple Accordion uses the tertiary button and does not support providing a custom button.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

@kaitlyn-owen
kaitlyn-owen force-pushed the FE-7867 branch 2 times, most recently from d59112e to 66b24f8 Compare November 30, 2026 10:22
@kaitlyn-owen
kaitlyn-owen marked this pull request as ready for review November 30, 2026 10:23
@kaitlyn-owen
kaitlyn-owen requested review from a team as code owners November 30, 2026 10:23
@kaitlyn-owen
kaitlyn-owen requested a balanced review from Copilot November 30, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The accordion documentation heading does not match the SubtleVariant story export, causing the skills drift check to fail and requiring regeneration.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the Accordion button customization change.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@DipperTheDan
DipperTheDan self-requested a review November 30, 2026 14:34
import Button from "../button/__next__";
import useMediaQuery from "../../hooks/useMediaQuery";

export interface RenderButtonProps {

@DipperTheDan DipperTheDan Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ActionPopover exports the RenderButtonProps so I agree we should probably do the same here

@nuria1110
nuria1110 self-requested a review November 30, 2026 15:54
},
};

export const SubtleVariant: Story = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants