Skip to content

fix(component): fix animation error in post-collapsible rendered inside inactive tabs #5502

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

Open
wants to merge 11 commits into
base: release/v8
Choose a base branch
from
5 changes: 5 additions & 0 deletions .changeset/tricky-buckets-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Resolved an issue where `post-accordion` components placed within inactive tab panels caused animation-related exceptions.
2 changes: 1 addition & 1 deletion packages/components/src/animations/collapse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const collapseDuration = 350;
const collapseEasing = 'ease';
const collapsedKeyframe: Keyframe = { height: '0', overflow: 'hidden' };
export const collapsedKeyframe: Keyframe = { height: '0', overflow: 'hidden' };

const animationOptions: KeyframeAnimationOptions = {
duration: collapseDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Watch,
} from '@stencil/core';
import { version } from '@root/package.json';
import { collapse, expand } from '@/animations/collapse';
import { collapse, collapsedKeyframe, expand } from '@/animations/collapse';
import { checkEmptyOrType, isMotionReduced } from '@/utils';

/**
Expand Down Expand Up @@ -40,8 +40,18 @@ export class PostCollapsible {
'boolean',
'The `collapsed` property of the `post-collapsible` must be a boolean.',
);

void this.toggle(!this.collapsed);

const expandedKeyframe: Keyframe = { height: 'auto', overflow: 'visible' };

if (!this.isLoaded) {
Object.assign(
this.host.style,
this.collapsed ? collapsedKeyframe : expandedKeyframe
);
this.isOpen = !this.collapsed;
} else {
void this.toggle(!this.collapsed);
}
}

/**
Expand Down