Skip to content

Commit d10b03c

Browse files
dmytro-halimovdhalimovdanielleroux
authored
fix(core/breadcrumb): Remove fade-in animation for breadcrumb-item #IX-4265 (#2549)
Co-authored-by: Dmytro Halimov <dhalimov@n-ix.com> Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
1 parent c8868e0 commit d10b03c

2 files changed

Lines changed: 28 additions & 58 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@siemens/ix': patch
3+
---
4+
5+
**ix-breadcrumb-item:** Remove the slide-in (`translateX` + opacity) enter animation, and propagate `aria-label` (and other host-level ARIA attributes) to the inner button

packages/core/src/components/breadcrumb-item/breadcrumb-item.tsx

Lines changed: 23 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ import {
1616
h,
1717
Host,
1818
Prop,
19-
State,
2019
Mixin,
2120
Watch,
2221
} from '@stencil/core';
23-
import { animate } from 'animejs';
2422
import { BaseButton, BaseButtonProps } from '../button/base-button';
25-
import { A11yAttributes, a11yHostAttributes } from '../utils/a11y';
2623
import { iconChevronRightSmall } from '@siemens/ix-icons/icons';
27-
import Animation from '../utils/animation';
2824
import { AnchorInterface, AnchorTarget } from '../button/button.interface';
2925
import { DefaultMixins } from '../utils/internal/component';
30-
import { requestAnimationFrameNoNgZone } from '../utils/requestAnimationFrame';
26+
import {
27+
InheritAriaAttributesMixin,
28+
InheritAriaAttributesMixinContract,
29+
} from '../utils/internal/mixins/accessibility/inherit-aria-attributes.mixin';
3130
import type { BreadcrumbClick } from '../breadcrumb/breadcrumb.types';
3231

3332
@Component({
@@ -36,8 +35,8 @@ import type { BreadcrumbClick } from '../breadcrumb/breadcrumb.types';
3635
shadow: true,
3736
})
3837
export class BreadcrumbItem
39-
extends Mixin(...DefaultMixins)
40-
implements AnchorInterface
38+
extends Mixin(...DefaultMixins, InheritAriaAttributesMixin)
39+
implements AnchorInterface, InheritAriaAttributesMixinContract
4140
{
4241
@Element() override hostElement!: HTMLIxBreadcrumbItemElement;
4342

@@ -97,22 +96,11 @@ export class BreadcrumbItem
9796
/**@internal */
9897
@Event() itemClick!: EventEmitter<BreadcrumbClick>;
9998

100-
@State() inheritAriaAttributes: A11yAttributes = {};
101-
102-
override componentDidLoad() {
103-
this.animationFadeIn();
104-
}
105-
10699
override componentWillLoad() {
107-
this.inheritAriaAttributes = a11yHostAttributes(this.hostElement, [
108-
'role',
109-
'aria-label',
110-
]);
100+
super.componentWillLoad();
111101
this.validateProps();
112102
}
113103

114-
override componentDidRender(): void {}
115-
116104
@Watch('breadcrumbKey')
117105
validateProps() {
118106
if (!this.breadcrumbKey) {
@@ -123,27 +111,21 @@ export class BreadcrumbItem
123111
}
124112
}
125113

126-
animationFadeIn() {
127-
animate(this.hostElement, {
128-
duration: Animation.defaultTime,
129-
opacity: [0, 1],
130-
translateX: ['-100%', '0%'],
131-
easing: 'linear',
132-
onComplete: () => {
133-
// this.hostElement.innerText is not available in componentWillLoad,
134-
// so we need to set aria-label in onComplete callback to ensure it is set after the content is rendered.
135-
requestAnimationFrameNoNgZone(() => {
136-
const ariaLabel =
137-
this.inheritAriaAttributes['aria-label'] ??
138-
this.label ??
139-
this.hostElement.innerText;
140-
this.hostElement.setAttribute('aria-label', ariaLabel);
141-
});
142-
},
143-
});
144-
}
145-
146114
override render() {
115+
if (this.invisible) {
116+
return <Host class={'invisible'} aria-hidden></Host>;
117+
}
118+
119+
const fallbackAriaLabel =
120+
this.label ?? this.hostElement.textContent?.trim();
121+
122+
const ariaAttributes = {
123+
...this.inheritAriaAttributes,
124+
'aria-label':
125+
this.inheritAriaAttributes['aria-label'] ?? fallbackAriaLabel,
126+
...(this.isCurrentPage ? { 'aria-current': 'page' } : {}),
127+
};
128+
147129
const props: BaseButtonProps = {
148130
variant: this.subtle ? 'subtle-primary' : 'tertiary',
149131
iconOnly: false,
@@ -159,38 +141,21 @@ export class BreadcrumbItem
159141
extraClasses: {
160142
'dropdown-trigger': this.isDropdownTrigger,
161143
},
162-
ariaAttributes: {
163-
...this.inheritAriaAttributes,
164-
'aria-label': this.inheritAriaAttributes['aria-label'],
165-
...(this.isCurrentPage ? { 'aria-current': 'page' } : {}),
166-
},
144+
ariaAttributes,
167145
href: this.href,
168146
target: this.target,
169147
rel: this.rel,
170148
};
171149

172-
if (this.invisible) {
173-
return <Host class={'invisible'} aria-hidden></Host>;
174-
}
175-
176-
const ariaAttributes = {
177-
...this.inheritAriaAttributes,
178-
'aria-label':
179-
this.inheritAriaAttributes['aria-label'] ??
180-
this.label ??
181-
this.hostElement.innerText,
182-
};
183-
184150
return (
185151
<Host
186-
{...ariaAttributes}
187152
class={{
188153
'hide-chevron': this.hideChevron,
189154
}}
190155
onClick={() =>
191156
this.itemClick.emit({
192157
breadcrumbKey: this.breadcrumbKey,
193-
label: this.label ?? this.hostElement.innerText,
158+
label: this.label ?? this.hostElement.textContent?.trim() ?? '',
194159
})
195160
}
196161
>

0 commit comments

Comments
 (0)