Skip to content

Commit 589663b

Browse files
committed
fix(action-card): render a button for proper accessibility
Wraps the inner `ix-card` of the `ix-action-card` in a `button`. This is aligned with the element approach.
1 parent d9fe735 commit 589663b

3 files changed

Lines changed: 63 additions & 42 deletions

File tree

.changeset/pink-sloths-drop.md

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+
Fix **ix-action-card** to render its content inside a `button` element so it is keyboard-focusable and exposed as a button to assistive technologies, improving accessibility.

packages/core/src/components/action-card/action-card.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,22 @@
2121

2222
@include component.ix-component;
2323

24+
25+
button {
26+
padding: 0;
27+
border: 0;
28+
border-radius: var(--theme-btn--border-radius);
29+
box-shadow: initial;
30+
31+
&:focus-visible {
32+
outline: 1px solid var(--theme-color-focus-bdr);
33+
outline-offset: var(--theme-btn--focus--outline-offset);
34+
}
35+
}
36+
2437
ix-card {
2538
width: 100%;
2639
height: 100%;
2740
}
2841
}
42+

packages/core/src/components/action-card/action-card.tsx

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99

1010
import { Component, h, Host, Prop } from '@stencil/core';
11-
import type { ActionCardVariant } from './action-card.types';
1211
import { a11yBoolean, getFallbackLabelFromIconName } from '../utils/a11y';
12+
import type { ActionCardVariant } from './action-card.types';
1313

1414
@Component({
1515
tag: 'ix-action-card',
@@ -75,48 +75,50 @@ export class IxActionCard {
7575

7676
return (
7777
<Host>
78-
<ix-card
79-
selected={this.selected}
80-
variant={this.variant}
81-
passive={this.passive}
82-
class={'pointer'}
83-
aria-label={this.ariaLabelCard}
84-
aria-labelledby={ariaLabelledBy}
85-
role={ariaLabelledBy ? 'group' : undefined}
86-
>
87-
<ix-card-content>
88-
{this.icon ? (
89-
<ix-icon
90-
class={'icon'}
91-
name={this.icon}
92-
size="32"
93-
aria-label={
94-
this.ariaLabelIcon || getFallbackLabelFromIconName(this.icon)
95-
}
96-
></ix-icon>
97-
) : null}
98-
<div>
99-
{this.heading ? (
100-
<ix-typography
101-
id="ix-action-card-heading"
102-
aria-hidden={a11yBoolean(!ariaLabelledBy)}
103-
format="h4"
104-
>
105-
{this.heading}
106-
</ix-typography>
107-
) : null}
108-
{this.subheading ? (
109-
<ix-typography
110-
format="h5"
111-
text-color={this.getSubheadingTextColor()}
112-
>
113-
{this.subheading}
114-
</ix-typography>
78+
<button>
79+
<ix-card
80+
selected={this.selected}
81+
variant={this.variant}
82+
passive={this.passive}
83+
class={'pointer'}
84+
aria-label={this.ariaLabelCard}
85+
aria-labelledby={ariaLabelledBy}
86+
>
87+
<ix-card-content>
88+
{this.icon ? (
89+
<ix-icon
90+
class={'icon'}
91+
name={this.icon}
92+
size="32"
93+
aria-label={
94+
this.ariaLabelIcon ||
95+
getFallbackLabelFromIconName(this.icon)
96+
}
97+
></ix-icon>
11598
) : null}
116-
<slot></slot>
117-
</div>
118-
</ix-card-content>
119-
</ix-card>
99+
<div>
100+
{this.heading ? (
101+
<ix-typography
102+
id="ix-action-card-heading"
103+
aria-hidden={a11yBoolean(!ariaLabelledBy)}
104+
format="h4"
105+
>
106+
{this.heading}
107+
</ix-typography>
108+
) : null}
109+
{this.subheading ? (
110+
<ix-typography
111+
format="h5"
112+
text-color={this.getSubheadingTextColor()}
113+
>
114+
{this.subheading}
115+
</ix-typography>
116+
) : null}
117+
<slot></slot>
118+
</div>
119+
</ix-card-content>
120+
</ix-card>
121+
</button>
120122
</Host>
121123
);
122124
}

0 commit comments

Comments
 (0)