Skip to content

Commit f635672

Browse files
feat(progresscircle): dashOffset a11y fix
to make sure a 0% fill progress circle meets contrast requirements, the dashOffset variable was created so that a small portion of the fill remains visible. this is a visual change only, and does not affect labels or aria-values
1 parent b931c5d commit f635672

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

2nd-gen/packages/swc/components/progress-circle/ProgressCircle.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ export class ProgressCircle extends ProgressCircleBase {
7676
// SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke.
7777
const radius = `calc(50% - ${strokeWidth / 2}px)`;
7878

79+
// At progress=0, a dashoffset of 100 makes the fill fully invisible, which fails WCAG 1.4.11
80+
// non-text contrast (the track alone may not meet 3:1 against the background).
81+
// Clamp to 98 to show a minimum 2-unit fill so the graphical element remains perceivable.
82+
// aria-valuenow stays at 0 — this is a visual-only adjustment.
83+
const dashOffset = this.indeterminate
84+
? 100 - this.progress
85+
: this.progress === 0
86+
? 98
87+
: 100 - this.progress;
88+
7989
return html`
8090
<div
8191
class=${classMap({
@@ -107,7 +117,7 @@ export class ProgressCircle extends ProgressCircleBase {
107117
class="swc-ProgressCircle-fill"
108118
pathLength="100"
109119
stroke-dasharray="100 200"
110-
stroke-dashoffset=${100 - this.progress}
120+
stroke-dashoffset=${dashOffset}
111121
stroke-linecap="round"
112122
/>
113123
</svg>

0 commit comments

Comments
 (0)