Skip to content

fix: guard ProgressBar/Meter percentage against NaN when min equals max#10169

Open
mvanhorn wants to merge 1 commit into
adobe:mainfrom
mvanhorn:fix/10042-progressbar-meter-nan-percentage
Open

fix: guard ProgressBar/Meter percentage against NaN when min equals max#10169
mvanhorn wants to merge 1 commit into
adobe:mainfrom
mvanhorn:fix/10042-progressbar-meter-nan-percentage

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

ProgressBar and Meter no longer emit NaN% when minValue equals maxValue.

Why this matters

Reported in #10042: when minValue === maxValue, the percentage calculation (value - minValue) / (maxValue - minValue) divides by zero and produces NaN, which surfaced both in the rendered width and the aria-valuetext percent label. The fix treats a zero range as 0% and supplies a 0% value label so assistive tech reads a real value.

Changes

  • Guard the percentage against a zero range in both ProgressBar and Meter.
  • When the range is zero and no explicit valueLabel is set, format 0 with the percent formatter so the label is 0% instead of NaN%.

Testing

Added ProgressBar and Meter tests for the minValue === maxValue case.

Fixes #10042

AI was used for assistance.

@snowystinger

Copy link
Copy Markdown
Member

Thanks for the PR. Which of these cases have you tried out and what were the results? #10042 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProgressBar and Meter produce NaN percentage when minValue === maxValue

2 participants