fix: guard ProgressBar/Meter percentage against NaN when min equals max#10169
Open
mvanhorn wants to merge 1 commit into
Open
fix: guard ProgressBar/Meter percentage against NaN when min equals max#10169mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
Member
|
Thanks for the PR. Which of these cases have you tried out and what were the results? #10042 (comment) |
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.
Summary
ProgressBarandMeterno longer emitNaN%whenminValueequalsmaxValue.Why this matters
Reported in #10042: when
minValue === maxValue, the percentage calculation(value - minValue) / (maxValue - minValue)divides by zero and producesNaN, which surfaced both in the rendered width and thearia-valuetextpercent label. The fix treats a zero range as 0% and supplies a0%value label so assistive tech reads a real value.Changes
ProgressBarandMeter.valueLabelis set, format0with the percent formatter so the label is0%instead ofNaN%.Testing
Added
ProgressBarandMetertests for theminValue === maxValuecase.Fixes #10042
AI was used for assistance.