fix: clear invalid drawn signature when switching to typed signature (#1536)

This commit is contained in:
Ephraim Duncan
2024-12-12 23:40:22 +00:00
committed by GitHub
parent 5fbed783fc
commit 10b8e785e0

View File

@ -351,10 +351,17 @@ export const SignaturePad = ({
const newValue = event.target.value;
setTypedSignature(newValue);
if ($el.current) {
const ctx = $el.current.getContext('2d');
ctx?.clearRect(0, 0, $el.current.width, $el.current.height);
}
if (newValue.trim() !== '') {
onChange?.(newValue);
onValidityChange?.(true);
} else {
onChange?.(null);
onValidityChange?.(false);
}
};