Skip to content

fix(#3625): Accordion Refinements#3766

Merged
ArakTaiRoth merged 1 commit intodevfrom
eric/3625-accordion-refinements
Apr 27, 2026
Merged

fix(#3625): Accordion Refinements#3766
ArakTaiRoth merged 1 commit intodevfrom
eric/3625-accordion-refinements

Conversation

@willcodeforcoffee
Copy link
Copy Markdown
Collaborator

@willcodeforcoffee willcodeforcoffee commented Apr 6, 2026

Before (the change)

Accordion is all unrefined and gross. 🤢

image

After (the change)

Fixed all discrepancies from issue #3625.

  • Large heading Accordion is 64px tall
  • Small heading Accordion is 48px tall
  • After size adjustments above:
    • the small heading text is vertically centered for
      • primary text
      • secondary text
    • large heading secondary text is vertically centered
  • Ensure other slotted elements are still vertically centered after update
  • Add motion tokens to animate the following:
    • "hover" - Background transform from white to grey use --goa-motion-duration-short-2
    • "open" - Show accordion content area use --goa-motion-curve-expressive and --goa-motionDuration-short-3
    • "close" - Hide accordion content area, use --goa-motion-curve-expressive-exit and --goa-motionDuration-short-3
image

Make sure that you've checked the boxes below before you submit the PR

  • I have read and followed the setup steps
  • I have created necessary unit tests
  • I have tested the functionality in both React and Angular.

Steps needed to test

Make sure you check out the eric/3625-accordion-refinements branch from design-tokens and update package.json devDependencies to use it:

"@abgov/design-tokens": "file://../design-tokens",
"@abgov/design-tokens-v2": "npm:@abgov/design-tokens@2.2.1",

Run npm i after making the change.

This PR will close Issue #3625

@willcodeforcoffee willcodeforcoffee self-assigned this Apr 6, 2026
@willcodeforcoffee willcodeforcoffee added Accordion 2.0 P3 Priority 3 (nice to have): Valuable, but safe to release after launch. labels Apr 6, 2026
@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from 25f7b18 to acd6c01 Compare April 6, 2026 21:47
background-color: var(--goa-accordion-color-bg-heading-hover);
border: var(--goa-accordion-border-hover, var(--goa-accordion-border));
color: var(--goa-accordion-color-heading-hover);
transition: var(--goa-motion-duration-medium-1) background-color
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets use --goa-motionDuration-short-2 to align more closely with the "short-2" we are using for other similar elements.

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from 7415d38 to 6134646 Compare April 9, 2026 02:43
@willcodeforcoffee willcodeforcoffee linked an issue Apr 9, 2026 that may be closed by this pull request
@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from 6134646 to aab8bdc Compare April 9, 2026 03:08
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 9, 2026

Deploy Preview for benji-docs-previews ready!

Name Link
🔨 Latest commit f06e851
🔍 Latest deploy log https://app.netlify.com/projects/benji-docs-previews/deploys/69ea34b3180f3b000834424b
😎 Deploy Preview https://deploy-preview-3766--benji-docs-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch 2 times, most recently from 5c66489 to 6053134 Compare April 10, 2026 22:25
@willcodeforcoffee willcodeforcoffee marked this pull request as ready for review April 10, 2026 22:48
Copy link
Copy Markdown
Collaborator

@bdfranck bdfranck left a comment

Choose a reason for hiding this comment

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

I tested the changes in the latest browsers...

Safari (Latest)

  • ✅ The sizes look good
  • ✅ The animation works as expected

Chrome (Latest)

  • ✅ The sizes look good
  • ✅ The animation works as expected

Chrome (Latest)

  • ✅ The sizes look good
  • ✅ The animation works as expected

Looks good! I left a couple minor comments.

background-color: var(--goa-accordion-color-bg-heading-hover);
border: var(--goa-accordion-border-hover, var(--goa-accordion-border));
color: var(--goa-accordion-color-heading-hover);
transition: var(--goa-motion-duration-short-2) background-color
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add the transition to the base summary selector on line 338 so the transitions both works on hover and blur.

}

.heading {
.heading-small {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Image

I'm still seeing the small heading is 50px instead of 48px. Is the dependency because of the borders?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤔 Hmm, you're right! I must not have included the borders in my calculations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@bdfranck I was able to fix this, you just need to get the latest of design-tokens first.

}

.heading-medium {
line-height: 2rem;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm still seeing the medium heading is 66px instead of 64px. Is the dependency because of the borders?

Image

event.stopPropagation();
}

function onAccordionToggle(target: EventHandler) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When I slowed down the animation in the Chrome Dev Tools Animation panel, I noticed that it wasn't including the component's bottom border. Is there an easy way to address this? 🤔

Image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@bdfranck 🤔 🤔 🤔 I believe this is a consequence of animating it using height attributes..? Do you have a suggestion? Maybe if I animate the height of an internal div instead? I can try that and see what I can do...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

After team discussion, we'll leave this animation as is.

Comment thread libs/web-components/src/components/accordion/Accordion.svelte
Comment thread libs/web-components/src/components/accordion/Accordion.svelte
Comment thread libs/web-components/src/components/accordion/Accordion.svelte Outdated
Comment thread libs/web-components/src/components/accordion/Accordion.svelte
Comment thread libs/web-components/src/components/accordion/Accordion.svelte Outdated
Comment thread libs/web-components/src/components/accordion/Accordion.svelte Outdated
@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch 4 times, most recently from ad8c172 to 37d01c3 Compare April 15, 2026 23:34
@willcodeforcoffee
Copy link
Copy Markdown
Collaborator Author

Addressed feedback:

  • moved the transition to the base summary
  • fixed the sizes of the headings
  • fixed animation speed to --goa-motion-duration-short-3 instead of short-2
  • added warning message and fallback so the accordion still works if the wrong version of design-tokens is included
  • changed EventHandler type to Event
  • open and aria-expanded attributes work correctly
  • removed commented CSS

@bdfranck @vanessatran-ddi ready for a re-review! 🙏

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from 40fb671 to f8344c0 Compare April 16, 2026 22:50
Copy link
Copy Markdown
Collaborator

@bdfranck bdfranck left a comment

Choose a reason for hiding this comment

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

I looked at the latest changes with the tokens from GovAlta/design-tokens#145...

  • ✅ The small heading height is 48px and the medium heading height is 64px
  • ✅ I see aria-expanded is true when the accordion is open
  • ✅ The animation works as expected
Image

Looks good to me! 👍

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from f8344c0 to 29e71af Compare April 20, 2026 15:25
Comment thread libs/web-components/src/components/accordion/Accordion.svelte Outdated
Comment thread libs/web-components/src/components/accordion/Accordion.svelte Outdated
@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch 2 times, most recently from 1486140 to 3aa2673 Compare April 21, 2026 01:53
@willcodeforcoffee
Copy link
Copy Markdown
Collaborator Author

Finished addressing comments:

  • open instead of isOpen
  • refactored the CSS time parsing

Thanks again for the thoughtful feedback @vanessatran-ddi .

Copy link
Copy Markdown
Collaborator

@vanessatran-ddi vanessatran-ddi left a comment

Choose a reason for hiding this comment

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

Looks good!

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch 2 times, most recently from 35ea306 to f06e851 Compare April 23, 2026 15:03
@willcodeforcoffee
Copy link
Copy Markdown
Collaborator Author

@ArakTaiRoth This is ready to merge! 🙏

// If the animation is cancelled, isClosing variable is set to false
_animation.oncancel = () => (_isClosing = false);

open = "false";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Because we're setting open to false here, before onAnimationFinish actually finishes. This causes the content to disappear before the Accordion actually closes.

jam.dev

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ArakTaiRoth Good catch, I wasn't looking close enough at the animation afterwards!
This is now fixed. I didn't see any issues or regressions.

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from f06e851 to f99df28 Compare April 27, 2026 19:54
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-27 22:46 UTC

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

Preview removed

All preview folders cleaned from gh-pages branch.


function onAnimationFinish(isAccordionOpen: boolean) {
// Set the open attribute based on the parameter
_detailsEl.open = isAccordionOpen;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm really sorry about this. But your previous fix for my last issue introduced a new issue. Now because open isn't being set to false anymore in shrink(), aria-expanded isn't being updated properly, so now when you close an accordion, aria-expanded still reads as true, you can test this with any accordion in your PR example.

I would suggest maybe moving the open property handling to onAnimationFinish instead of handling it in shrink() or expand(), and just changing what the value is everytime it's run, open = isAccordionOpen ? "true" : "false";.

You have this line here that handles _detailsEl.open, but that doesn't modify open, which is what's deriving isOpen, which is what's used for aria-expanded.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ArakTaiRoth another good catch! 🤦 Sorry I missed that one, too. 😞

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from f99df28 to 164f54d Compare April 27, 2026 20:41
}

function onAnimationFinish(isAccordionOpen: boolean) {
console.log("onfinish");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

falling down

@willcodeforcoffee willcodeforcoffee force-pushed the eric/3625-accordion-refinements branch from 164f54d to 18e0383 Compare April 27, 2026 22:24
@ArakTaiRoth ArakTaiRoth merged commit 8346d85 into dev Apr 27, 2026
5 checks passed
@ArakTaiRoth ArakTaiRoth deleted the eric/3625-accordion-refinements branch April 27, 2026 22:45
@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.0.0-dev.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 7.0.0-dev.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 5.0.0-dev.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisolsen
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.0.0-dev.6 🎉

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

Labels

2.0 Accordion P3 Priority 3 (nice to have): Valuable, but safe to release after launch. released on @dev

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accordion refinement

6 participants