Skip to content

Show progress percentage with one decimal and prevent overfill - #551

Open
jessejacksonafterpay wants to merge 1 commit into
cashapp:masterfrom
jessejacksonafterpay:progress-bar-decimals
Open

Show progress percentage with one decimal and prevent overfill#551
jessejacksonafterpay wants to merge 1 commit into
cashapp:masterfrom
jessejacksonafterpay:progress-bar-decimals

Conversation

@jessejacksonafterpay

Copy link
Copy Markdown

Summary

  • The ProgressBar component rounded the computed percentage to a whole number with round((numerator / denominator) * 100). At 99.6% this rounded to 100, so the bar visually filled to 100% and the label read "100%" while the backfill wasn't actually complete.
  • Drop the rounding, compute the true percentage, and floor it to one decimal place. Use the same floored value for both the inline label and the width: style, so the rendered fill can never exceed the actual progress.
  • Display the label with one decimal (e.g. 99.6%).

Notes

  • BackfillShowAction already uses String.format("%.1f", percentage) for the standalone "Overall Progress" label above the bar, so this brings the bar's inline label in line with that.
  • Floor (rather than round) at the displayed precision is intentional: it preserves the "not 100% until truly done" property at any precision.

The progress bar rounded the percentage to a whole number, so 99.6%
displayed as 100% with the bar filled all the way. Compute the true
percentage and floor it to one decimal so the rendered width and
label can never overstate progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant