Skip to content

fix(ui): reset signature dialog state on cancel and reopen - #3257

Closed
misinierijon4-debug wants to merge 1 commit into
documenso:mainfrom
misinierijon4-debug:fix/issue-3203-reset-signature-state-on-dialog-close
Closed

misinierijon4-debug wants to merge 1 commit into
documenso:mainfrom
misinierijon4-debug:fix/issue-3203-reset-signature-state-on-dialog-close

Conversation

@misinierijon4-debug

Copy link
Copy Markdown
Contributor

Problem

When a user draws a signature in SignaturePadDialog, cancels the modal, and subsequently reopens the dialog, the drawing was kept in local signature state. Because the modal's inner content unmounts on close, reopening displayed the parent value (which could be blank) while the stale drawing remained held in local state. Clicking Next/Confirm then committed the abandoned drawing.

Root cause

In packages/ui/primitives/signature-pad/signature-pad-dialog.tsx, signature state was declared outside the <Dialog> and initialized with useState(value ?? ''). When the dialog was closed via cancel or backdrop click, local state was never reset back to value ?? ''.

Change

  1. Updated onOpenChange on <Dialog> to reset signature to value ?? '' whenever the dialog closes.
  2. Updated the trigger button's onClick to ensure signature is initialized to value ?? '' upon opening.

Proof

Test Red (Before Fix)

Buggy commit after cancel & reopen: abandoned_drawing

Test Green (After Fix)

PS C:\Users\erijo\Downloads\claude> node --test test_reproduce_issue_3203.mjs
▶ Documenso Issue #3203: Signature Pad State Isolation on Cancel/Reopen
  ✔ reproduces bug: cancelled drawing persists in local state and gets committed on subsequent confirm (1.4901ms)
  ✔ verified fix: cancelling or reopening resets signature state to parent value (0.2617ms)
✔ Documenso Issue #3203: Signature Pad State Isolation on Cancel/Reopen (2.9783ms)
ℹ tests 2
ℹ suites 1
ℹ pass 2
ℹ fail 0

Reference

Fixes #3203

@vercel

vercel Bot commented Aug 18, 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 Aug 28, 2026 4:38pm
prd-openpage-api Ignored Ignored Aug 28, 2026 4:38pm
stg-docs Skipped Skipped Aug 28, 2026 4:38pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – stg-docs August 18, 2026 20:54 Inactive
@coderabbitai

coderabbitai Bot commented Aug 18, 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 Plus

Run ID: c002a62d-1d41-4a43-955a-3182b68fc262

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

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.

@Mythie

Mythie commented Aug 18, 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

@misinierijon4-debug
misinierijon4-debug force-pushed the fix/issue-3203-reset-signature-state-on-dialog-close branch from 5ce7e1e to f6b45f8 Compare August 28, 2026 16:38
@vercel
vercel Bot temporarily deployed to Preview – stg-docs August 28, 2026 16:38 Inactive

<Dialog open={showSignatureModal} onOpenChange={disabled ? undefined : setShowSignatureModal}>
<Dialog
open={showSignatureModal}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix seems correct. Please extract the reset into a single onOpenChange(open) handler. Something like:

const onOpenChange = (open: boolean) => {
     if (disabled) {
       return;
     }

     setSignature(value ?? '');
     setShowSignatureModal(open);
   };

@catalinpit

Copy link
Copy Markdown
Member

Thanks for working on this! Since the requested changes haven't been addressed, I've combined this and a similar PR into #3408, so I'm closing this one.

This branch was previously deployed

1 inactive deployment
Preview – stg-docs — f6b45f87 Deployed Aug 28, 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.

Signature pad keeps a discarded drawing in local state and commits it on the next confirm

3 participants