Skip to content

feat(accordion): align to Fusion DS#7842

Merged
nuria1110 merged 2 commits intomasterfrom
accordion-audit
Apr 16, 2026
Merged

feat(accordion): align to Fusion DS#7842
nuria1110 merged 2 commits intomasterfrom
accordion-audit

Conversation

@nuria1110
Copy link
Copy Markdown
Contributor

Proposed behaviour

Aligns Accordion with Fusion DS and updates styles with fusion-tokens.

  • Changes icon type depending on variant/size selected.
  • Sets "medium" size as default.
  • HeaderSpacing storybook example shows how to achieve 'No padding' variation.

"Standard" variant:

  • Supports size "small" and "medium"
image

"Simple" variant:

  • Renames "subtle" variant to "simple".
  • Renders "tertiary" next Button.
  • "Simple" variant supports size "small", "medium" and "large":
image

Deprecated props:

  • "full" option in borders
  • "subtle" option in variant
  • disableContentPadding
  • iconType
  • iconAlign
  • error
  • warning
  • info

Current behaviour

Accordion is not aligned with Fusion DS.

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

);

// temporary wrapper for deprecated validation
const renderTitleWithValidation = () => (
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 (non-blocking): honestly we could drop this completely and just let the validation related props have no effect. Depends on how nice we want to be with this, could be worth testing the water to see what the actual consumer impact would be.

But if you want to leave this in, It's completely fine and won't be a blocker on my end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't mind, thought I would be nice for this one but hopefully no one is using these anymore. I'll probably just remove to clean it up a bit more.

<Button
data-role="accordion-simple-button"
id={headerId}
aria-expanded={isExpanded}
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 (non-blocking): in this ternary here when we're rendering the "simple button" or the title container, bothy have a lot of shared props. We could potentially put all shared props between the two in an object like titleProps etc, then spread them onto both instances.

This is just personal preference though, if you prefer to do it like this feel free to leave it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I personally avoid putting props into objects as I've seen in some legacy components they can get quite messy, I'll probably leave it like this, I also think it helps in terms of readability.

role="button"
$size={standardSize}
$iconAlign={iconAlign}
{...headerSpacing}
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.

question: would consumers expect this header spacing to also be applied to the "simple button"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Depends I guess, I was mainly repurposing this prop to apply the different header spacing variations in the DS so I didn't think it was really necessary to pass it to both variants. Since the title prop also accepts a node if someone really wanted to change the default button spacing they could just pass their own wrapper with spacing.

>
{actualVariant === "simple" && <StyledAccordionLine />}
<StyledAccordionContent
role="region"
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.

question: do we need a role of "region" here? I understand you didn't add this and its a legacy implementation, but an aria-live region seems unnecessary as the other aria- attributes we're using should be enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think "region" roles come with an aria-live, but I agree that its probably not necessary. I'll double check with the accessibility team.

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.

Yeah mb, got confused

isExpanded={isExpanded}
maxHeight={contentHeight}
$isExpanded={isExpanded}
$height={contentHeight}
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: I see we're passing height down here, which we get from a useResizeObserver and a side effect. We then use this height in the styled component file like so

${$height}px;

I think we can avoid doing this by simply making the height of the accordion when expanded fit its content.

height: fit-content;

If this suggestion does work, we can remove this expensive computations which is re-triggered on every re-size event or when the component is expanded.

Copy link
Copy Markdown
Contributor Author

@nuria1110 nuria1110 Mar 25, 2026

Choose a reason for hiding this comment

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

I'll have another look but I tested quite a few ways to set the height and they all seemed to break the animation in some way - I'll try to see if I can simplify the events anyways.

width?: string;
/** Sets accordion variant */
variant?: "standard" | "subtle";
interface StyledAccordionContainerProps {
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 a similar sort of interface is declared a lot here with various different combinations of the transient $ prefix props you've used. You could benefit from using one shared interface, then just picking from that wherever you need below.

/** Sets accordion variant */
variant?: "standard" | "subtle";
interface StyledAccordionContainerProps {
$borders?: "default" | "full" | "none";
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 (non-blocking): even though these are transient props you could link up their types to be that of the OG interface, therefore if more types are ever added in the actual prop these don't have to be updated manually.


const testData = [CHARACTERS.DIACRITICS, CHARACTERS.SPECIALCHARACTERS];

test.describe("should render Accordion component", () => {
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 (non-blocking): after a quick glance through this file we could purge even more tests which are not strictly interaction tests (not including the accessibility tests) e.g. asserting the title or subtitle props work could be removed as these are covered in unit tests and chromatic snapshots

accordionContent,
accordion,
};
export default accordionDefaultTitle;
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 we no longer use this in accordions pw tests it seems, just seems to be left in action-popover and split-button. You could just replace those instances with a direct data-element check and delete this entire folder.

tomdavies73
tomdavies73 previously approved these changes Mar 30, 2026
@nuria1110 nuria1110 marked this pull request as ready for review March 30, 2026 08:59
@nuria1110 nuria1110 requested review from a team as code owners March 30, 2026 08:59
@designerlisa
Copy link
Copy Markdown

designerlisa commented Apr 2, 2026

Hi @nuria1110 , all looks great, just a few finding here:

  1. Control panel (1) still shows 'right' option in radio buttons

  2. Control panel (2) still has manual icon selection (including down arrow icon)

  • These controls should be removed (if possible, so dev won't accidently change to a wrong icon like my screenshot using the wrong icon.)
  • The down arrow should be removed
image

@designerlisa
Copy link
Copy Markdown

Checked with @nuria1110 regarding these findings. Those options are deprecated and will be removed in the future breaking change as per the general approach. @ljemmo are we aligned to proceed as-is?

Once confirmed, I'll move this to QA passed.

@ljemmo
Copy link
Copy Markdown
Contributor

ljemmo commented Apr 13, 2026

@designerlisa yes thats the expectation. We want to give consuming teams a chance to understand that elements will be removed in the near future and have chance to migrate to alternative properties.

@nuria1110 nuria1110 dismissed stale reviews from mihai-albu-sage and tomdavies73 via cb6f2f6 April 15, 2026 10:50
@nuria1110 nuria1110 marked this pull request as draft April 15, 2026 10:51
@nuria1110 nuria1110 marked this pull request as ready for review April 15, 2026 11:36
Aligns `Accordion` to Fusion DS. Deprecates props which are no longer relevant and updates
styleswith fusion-tokens.
@nuria1110 nuria1110 merged commit b0ab242 into master Apr 16, 2026
28 checks passed
@nuria1110 nuria1110 deleted the accordion-audit branch April 16, 2026 14:08
@carbonci
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 158.42.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

8 participants