Compare commits

...
Author SHA1 Message Date
Catalin Pit 8b182e474c Merge branch 'main' into fix/signature-pad-dialog-reset-on-cancel 2026-09-28 16:51:38 +03:00
Catalin Pit 95fbdb3600 fix(ui): discard cancelled signature pad dialog drafts
The dialog kept its draft signature in state across open/close, while
the pad inside remounts from the saved value. After cancelling,
reopening showed the saved signature (or an empty pad), but the Next
button stayed enabled and committed the discarded draft.

Reset the draft to the saved value whenever the dialog opens or closes,
and route all open-state changes through one disabled-aware handler.
2026-09-28 14:41:12 +01:00
@@ -41,6 +41,15 @@ export const SignaturePadDialog = ({
const [showSignatureModal, setShowSignatureModal] = useState(false);
const [signature, setSignature] = useState<string>(value ?? '');
const onOpenChange = (open: boolean) => {
if (disabled) {
return;
}
setSignature(value ?? '');
setShowSignatureModal(open);
};
return (
<div
className={cn(
@@ -62,7 +71,7 @@ export const SignaturePadDialog = ({
type="button"
disabled={disabled}
className="absolute inset-0 flex items-center justify-center bg-transparent"
onClick={() => setShowSignatureModal(true)}
onClick={() => onOpenChange(true)}
whileHover="onHover"
>
{!value && !disableAnimation && (
@@ -109,7 +118,7 @@ export const SignaturePadDialog = ({
)}
</motion.button>
<Dialog open={showSignatureModal} onOpenChange={disabled ? undefined : setShowSignatureModal}>
<Dialog open={showSignatureModal} onOpenChange={onOpenChange}>
<DialogContent hideClose={true} className="p-6 pt-4">
<SignaturePad
id="signature"
@@ -135,7 +144,7 @@ export const SignaturePadDialog = ({
disabled={!signature}
onClick={() => {
onChange(signature);
setShowSignatureModal(false);
onOpenChange(false);
}}
>
{dialogConfirmText ? parseMessageDescriptor(i18n._, dialogConfirmText) : <Trans>Next</Trans>}