Skip to content

fix(milestones): guard against zero budget divide and clamp progress consistently (#75) - #101

Open
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/issue-75-milestones-progress-clamp
Open

ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/issue-75-milestones-progress-clamp

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Closes #75

This PR resolves the divide-by-zero, misleading Infinity percentage rendering, and unclamped over-100% display in MilestonesPage:

  1. Guard against zero/negative budget: When m.budget <= 0, MilestonesPage now explicitly avoids dividing by zero (0 / 0 producing NaN in the inline style width and X / 0 producing misleading Infinity that was rendered as "0%"). Instead, an honest "Not yet funded" label is shown with a 0% progress bar.
  2. Clamped progress & consistent visual state: Clamps clampedPct = Math.max(0, Math.min(rawPct, 1)) ensuring the progress bar width and the percentage readout agree and remain within [0%, 100%].
  3. Over-budget visual indicator: When distributed > budget (and budget > 0), surfaces a clear Over-budget badge alongside the capped 100% progress.
  4. Deduplicated helper & unit tests: Removed duplicate declaration of validateTeamSplits in utils.ts and added unit tests in src/lib/utils.test.ts verifying formatPercent, formatCurrency, coerceFraction, coercePercentage, and validateTeamSplits.

Verification

  • npm run build passes with 0 errors / 0 type issues.
  • npx jest src/lib/utils.test.ts passes all 9 unit tests.

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

MilestonesPage divides by zero on an unfunded budget and never clamps an over-100% distributed percentage

1 participant