Skip to content

Commit

Permalink
feat(accordion): rename initialLoad state to hasRenderedOnce for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ckrook committed Dec 18, 2024
1 parent f4bb00d commit aa08be3
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class TdsAccordionItem {
* Private boolean to track if this is the initial load.
* If true, we skip triggering the animation classes on first render.
*/
@State() private initialLoad = true;
@State() private hasRenderedOnce = false;

/** Method for toggling the expanded state of the Accordion Item. */
@Method()
Expand Down Expand Up @@ -64,7 +64,7 @@ export class TdsAccordionItem {
render() {
// If initialLoad is true, we do NOT attach the animation classes
// so it won't animate on the very first render.
const shouldAnimate = this.animation !== 'none' && !this.initialLoad;
const shouldAnimate = this.animation !== 'none' && this.hasRenderedOnce;

// Build up dynamic classes
const classes = {
Expand All @@ -75,7 +75,7 @@ export class TdsAccordionItem {
[`tds-accordion-item-animation-close-${this.animation}`]: shouldAnimate && !this.expanded,
};

this.initialLoad = false;
this.hasRenderedOnce = true;

return (
<Host>
Expand Down

0 comments on commit aa08be3

Please sign in to comment.