Skip to content

fix: prevent division by zero in progress bar when requiredRecipientFields is empty - #2855

Merged
dguyen merged 4 commits into
documenso:mainfrom
durgeshhhhhhh:fix/division-by-zero-in-progress-bar
May 26, 2026
Merged

dguyen merged 4 commits into
documenso:mainfrom
durgeshhhhhhh:fix/division-by-zero-in-progress-bar

Conversation

@durgeshhhhhhh

Copy link
Copy Markdown
Contributor

Description

When a recipient has zero required fields, the progress bar width formula 100 / requiredRecipientFields.length produces Infinity (or NaN), breaking progress bar rendering in both the mobile widget and desktop sidebar view.
Fixes bugs #16 and #17 from issue #2829

Related Issue

Part of #2829

Changes Made

  • Added a zero-length guard in document-signing-mobile-widget.tsx
    to return 100% width when "requiredRecipientFields" is empty

  • Added the same guard in document-signing-page-view-v2.tsx for
    consistency across both mobile and desktop views

Testing Performed

  • Reproduced the bug locally: with 0 required fields, console showed width: NaN% and progress bar appeared empty/broken

  • After fix: console shows width: 100% and progress bar renders as fully complete

  • Tested with 2 required fields: progress bar correctly starts at 0% and fills as fields are completed

  • Tested on Chrome on macOS

Checklist

  • I have tested these changes locally, and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Additional Notes

Before fix (progress bar broken — width: NaN%):

Screenshot 2026-05-23 at 3 37 32 PM

After fix (progress bar fully complete — width: 100%):

Screenshot 2026-05-23 at 3 38 18 PM

Copilot AI review requested due to automatic review settings May 23, 2026 10:54
@vercel

vercel Bot commented May 23, 2026

Copy link
Copy Markdown

@durgeshhhhhhh is attempting to deploy a commit to the Documenso Team Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 452acafe-5051-4368-91de-999c66640e7e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel

vercel Bot commented May 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
prd-docs Ignored Ignored May 26, 2026 4:19am
prd-openpage-api Ignored Ignored May 26, 2026 4:19am
stg-docs Skipped Skipped May 26, 2026 4:19am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Prevent invalid progress bar width calculations in document-signing UI when there are no required recipient fields.

Changes:

  • Guard progress bar width calculation against division-by-zero when requiredRecipientFields.length === 0.
  • Apply the same fix to both desktop/page view and mobile widget progress bars.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/remix/app/components/general/document-signing/document-signing-page-view-v2.tsx Adds a zero-length guard to prevent invalid progress width computation.
apps/remix/app/components/general/document-signing/document-signing-mobile-widget.tsx Mirrors the same zero-length guard for the mobile progress bar.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

className="absolute inset-y-0 left-0 bg-primary"
style={{
width: `${100 - (100 / requiredRecipientFields.length) * (recipientFieldsRemaining.length ?? 0)}%`,
width: `${requiredRecipientFields.length === 0 ? 100 : 100 - (100 / requiredRecipientFields.length) * (recipientFieldsRemaining.length ?? 0)}%`,
className="absolute inset-y-0 left-0 bg-primary"
style={{
width: `${100 - (100 / requiredRecipientFields.length) * (recipientFieldsRemaining.length ?? 0)}%`,
width: `${requiredRecipientFields.length === 0 ? 100 : 100 - (100 / requiredRecipientFields.length) * (recipientFieldsRemaining.length ?? 0)}%`,
@Mythie

Mythie commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Hey there, it looks like you haven't accepted our contributor license agreement yet. In order for us to accept your pull request we ask that you please fill out the CLA:

https://documen.so/cla

@vercel
vercel Bot temporarily deployed to Preview – stg-docs May 23, 2026 11:07 Inactive
@vercel

vercel Bot commented May 23, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

@vercel
vercel Bot temporarily deployed to Preview – stg-docs May 26, 2026 03:37 Inactive

@dguyen dguyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@vercel
vercel Bot temporarily deployed to Preview – stg-docs May 26, 2026 04:19 Inactive
@dguyen
dguyen merged commit 6bb0496 into documenso:main May 26, 2026
8 of 9 checks passed
scoobs-mystery-bytes pushed a commit to scoobs-mystery-bytes/documenso that referenced this pull request May 30, 2026

This branch was previously deployed

1 inactive deployment
Preview – stg-docs — 84b23278 Deployed May 26, 2026 by vercel[bot]
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.

4 participants