fix(core): guard ProgressBar value label against zero max#3742
Open
raphaelroshanM wants to merge 1 commit into
Open
fix(core): guard ProgressBar value label against zero max#3742raphaelroshanM wants to merge 1 commit into
raphaelroshanM wants to merge 1 commit into
Conversation
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).
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
ProgressBaris givenmax={0}withhasValueLabel, the default value-label formatter divides by zero and producesNaN%(from0/0) orInfinity%(fromn/0). That string is rendered visually and written intoaria-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 sethasValueLabel, so it missed this. Extended it to cover the label andaria-valuetext.