Repository navigation
fix(ui): reset signature dialog state on cancel and reopen - #3257
misinierijon4-debug wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
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 |
5ce7e1e to
f6b45f8
Compare
|
|
||
| <Dialog open={showSignatureModal} onOpenChange={disabled ? undefined : setShowSignatureModal}> | ||
| <Dialog | ||
| open={showSignatureModal} |
There was a problem hiding this comment.
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);
};
|
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. |
Problem
When a user draws a signature in
SignaturePadDialog, cancels the modal, and subsequently reopens the dialog, the drawing was kept in localsignaturestate. Because the modal's inner content unmounts on close, reopening displayed the parentvalue(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,signaturestate was declared outside the<Dialog>and initialized withuseState(value ?? ''). When the dialog was closed via cancel or backdrop click, local state was never reset back tovalue ?? ''.Change
onOpenChangeon<Dialog>to resetsignaturetovalue ?? ''whenever the dialog closes.onClickto ensuresignatureis initialized tovalue ?? ''upon opening.Proof
Test Red (Before Fix)
Test Green (After Fix)
Reference
Fixes #3203