Skip to content

Commit 3c7f95b

Browse files
authored
refactor(progress): a11y optimizations (#535)
* refactor(progress): a11y optimizations * refactor(progress): adapted HTML for the testcase * refactor(progress): adapted HTML for the testcase * refactor(progress): adapted HTML for the testcase
1 parent bb61832 commit 3c7f95b

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

e2e/cypress/integration/06-0-feedback/db-progress.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ context('db-progress', () => {
99
it('Progress should exist and be configurable', function () {
1010
const simpleProgress = [0, 1];
1111
simpleProgress.forEach((num) => {
12-
cy.get('db-progress').eq(num).find('output').contains('60%');
12+
cy.get('db-progress').eq(num).find('label').contains('60%');
1313
cy.get('db-progress')
1414
.eq(num)
1515
.find('progress')
@@ -23,6 +23,6 @@ context('db-progress', () => {
2323
.invoke('attr', 'indeterminate')
2424
.should('exist');
2525

26-
cy.get('db-progress').eq(3).find('output').contains('60 ❤️');
26+
cy.get('db-progress').eq(3).find('label').contains('60 ❤️');
2727
});
2828
});

e2e/cypress/integration/99-1-showcases/showcases-other-elements.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ context('showcase', () => {
1414
.should('eq', 'account');
1515

1616
// 2. DbProgress
17-
cy.get('db-progress').eq(0).find('output').contains('60%');
17+
cy.get('db-progress').eq(0).find('label').contains('60%');
1818
cy.get('db-progress')
1919
.eq(0)
2020
.find('progress')

packages/db-ui-elements-stencil/src/components/db-progress/__tests__/db-progress.spec.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ describe('db-progress', () => {
1010
expect(page.root).toEqualHtml(`
1111
<db-progress htmlid="progress-label-01">
1212
<div class="elm-progress">
13-
<progress id="progress-label-01"></progress>
14-
<output htmlFor="progress-label-01">%</output>
13+
<progress aria-describedby="progress-label-01-label" id="progress-label-01"></progress>
14+
<label aria-hidden="true" htmlfor="progress-label-01" id="progress-label-01-label">
15+
%
16+
</label>
1517
</div>
1618
</db-progress>
1719
`);

packages/db-ui-elements-stencil/src/components/db-progress/db-progress.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ export class DbProgress {
4848
? { ['--progress-conic']: `${this.value}` }
4949
: { ['']: '' }
5050
}
51+
aria-describedby={this.htmlid + '-label'}
5152
/>
5253
{!this.indeterminate && (
53-
<output htmlFor={this.htmlid}>
54+
<label
55+
htmlFor={this.htmlid}
56+
id={this.htmlid + '-label'}
57+
aria-hidden="true"
58+
>
5459
{this.value}
5560
{this.percentagesign}
56-
</output>
61+
</label>
5762
)}
5863
</div>
5964
);

0 commit comments

Comments
 (0)