Skip to content

fix(core): guard ProgressBar value label against zero max#3742

Open
raphaelroshanM wants to merge 1 commit into
facebook:mainfrom
raphaelroshanM:fix/progressbar-zero-max-value-label
Open

fix(core): guard ProgressBar value label against zero max#3742
raphaelroshanM wants to merge 1 commit into
facebook:mainfrom
raphaelroshanM:fix/progressbar-zero-max-value-label

Conversation

@raphaelroshanM

Copy link
Copy Markdown
Contributor

When ProgressBar is given max={0} with hasValueLabel, the default value-label formatter divides by zero and produces NaN% (from 0/0) or Infinity% (from n/0). That string is rendered visually and written into aria-valuetext, so screen readers announce "NaN percent".

The fill percentage already guards this one line up (const percentage = max > 0 ? (clampedValue / max) * 100 : 0), so the label just needs the same guard. max={0} is a supported case — there's an existing "handles zero max gracefully" test, but it doesn't set hasValueLabel, so it missed this. Extended it to cover the label and aria-valuetext.

When max was 0 (or negative), the default value-label formatter produced
NaN% (0/0) or Infinity%, rendered visually and written into aria-valuetext
so screen readers announced "NaN percent". Guard it like the fill
percentage already is (max > 0 ? ... : 0).
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

@raphaelroshanM is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant