fix: avoid having a drawn and typed signature at the same time (#1516)
This commit is contained in:
@@ -191,8 +191,9 @@ export const SignaturePad = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const point = Point.fromEvent(event, DPI, $el.current);
|
const point = Point.fromEvent(event, DPI, $el.current);
|
||||||
|
const lastPoint = currentLine[currentLine.length - 1];
|
||||||
|
|
||||||
if (point.distanceTo(currentLine[currentLine.length - 1]) > 5) {
|
if (lastPoint && point.distanceTo(lastPoint) > 5) {
|
||||||
setCurrentLine([...currentLine, point]);
|
setCurrentLine([...currentLine, point]);
|
||||||
|
|
||||||
// Update the canvas here to draw the lines
|
// Update the canvas here to draw the lines
|
||||||
@@ -301,6 +302,7 @@ export const SignaturePad = ({
|
|||||||
setTypedSignature('');
|
setTypedSignature('');
|
||||||
setLines([]);
|
setLines([]);
|
||||||
setCurrentLine([]);
|
setCurrentLine([]);
|
||||||
|
setIsPressed(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderTypedSignature = () => {
|
const renderTypedSignature = () => {
|
||||||
@@ -349,6 +351,17 @@ export const SignaturePad = ({
|
|||||||
|
|
||||||
const handleTypedSignatureChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleTypedSignatureChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const newValue = event.target.value;
|
const newValue = event.target.value;
|
||||||
|
|
||||||
|
// Deny input while drawing.
|
||||||
|
if (isPressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lines.length > 0) {
|
||||||
|
setLines([]);
|
||||||
|
setCurrentLine([]);
|
||||||
|
}
|
||||||
|
|
||||||
setTypedSignature(newValue);
|
setTypedSignature(newValue);
|
||||||
|
|
||||||
if ($el.current) {
|
if ($el.current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user