Skip to content

feat(accordion): update to use correct HTML semantics #7272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

damienrobson-sage
Copy link
Contributor

@damienrobson-sage damienrobson-sage commented Mar 25, 2025

BREAKING CHANGE: Accordion has been rewritten to use the correct HTML semantics (details and summary). As such, defaultExpanded has been deprecated in favour of expanded. The AccordionGroup component has also been removed.

Proposed behaviour

  • Rebuild Accordion using the semantically-correct details and summary elements, whilst maintaining functionality.
  • Remove AccordionGroup.

Current behaviour

The current implementation of Accordion is built with div elements as opposed to the semantically-correct details and summary elements. This is due to legacy constraints whereby details/summary could not be animated.

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

  • After conversation with the accessibility team, the handler for keyboard interaction between grouped Accordion elements in AccordionGroup has been removed. The default behaviour of tabbing between components should be used instead;
  • Accordions can now be semantically grouped using the groupName prop as well as via the AccordionGroup component. Using the component approach, accordions will retain their open/closed state when other accordions are opened. Using the semantic approach, only one accordion can be open in a group at any given time;

Testing instructions

Use the updated Storybook examples to test the new functionalities.

Copy link
Contributor

@edleeks87 edleeks87 left a comment

Choose a reason for hiding this comment

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

Really good work @damienrobson-sage, it's great to now be able to use the semantically correct elements now. I notice when I've run the chromatic build there that some of the component is rendering slightly off screen, not sure if that'll affect chromatic but it does when viewing the docs etc. I also notice there's a tests story not sure if that's intentional.

@edleeks87 edleeks87 marked this pull request as draft March 27, 2025 14:51
@damienrobson-sage damienrobson-sage force-pushed the FE-4406-accordion-semantics branch 4 times, most recently from e4b66eb to 563f57b Compare March 28, 2025 14:24
@nuria1110 nuria1110 self-requested a review March 31, 2025 15:18
@damienrobson-sage damienrobson-sage force-pushed the FE-4406-accordion-semantics branch 3 times, most recently from d2d80ce to 7864b25 Compare April 1, 2025 16:07
@damienrobson-sage damienrobson-sage force-pushed the FE-4406-accordion-semantics branch from 7864b25 to 0a15312 Compare April 2, 2025 06:44
edleeks87
edleeks87 previously approved these changes Apr 2, 2025
@damienrobson-sage damienrobson-sage force-pushed the FE-4406-accordion-semantics branch 2 times, most recently from e16414a to 92dea15 Compare April 2, 2025 14:35
nuria1110
nuria1110 previously approved these changes Apr 3, 2025
edleeks87
edleeks87 previously approved these changes Apr 3, 2025
@edleeks87 edleeks87 marked this pull request as ready for review April 3, 2025 09:17
@harpalsingh
Copy link
Member

@damienrobson-sage looking into this, as it seems the way the content appears has changed so need to be sure this wont cause issues with larger content from an accoridon

@damienrobson-sage
Copy link
Contributor Author

@harpalsingh spun up a quick test of the component with 10 paragraphs worth of lorem ipsum (see below). Is this what you were wanting to check?

Screenshot 2025-04-07 at 08 21 35

@damienrobson-sage damienrobson-sage dismissed stale reviews from edleeks87 and nuria1110 via f38b506 April 11, 2025 10:22
BREAKING CHANGE: The `Accordion` component has been re-written to use the correct HTML
semantics (details and summary). As a result, the `defaultExpanded` prop has been removed;
please use the `expanded` prop in it's place.
@damienrobson-sage damienrobson-sage force-pushed the FE-4406-accordion-semantics branch from 93a9373 to d9f36bd Compare April 11, 2025 13:31
@damienrobson-sage damienrobson-sage deleted the FE-4406-accordion-semantics branch June 11, 2025 07:13
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