Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-crews-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend': patch
---

Fixed bug where signatures wouldn't be displayed correctly when more than one signature is on the page
2 changes: 1 addition & 1 deletion apps/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import http from 'http';
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '5000');
var port = normalizePort(process.env.PORT || '8080');
app.set('port', port);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
useEffect(() => {
if (!value?.signatureData || !sigCanvas.current || doesCanvasHaveData) return

sigCanvas?.current?.off()
const canvas = sigCanvas.current.getCanvas()
if (!canvas) return

Expand All @@ -30,7 +31,7 @@
)

setDoesCanvasHaveData(true)
setImmediate(() => sigCanvas.current?.fromData(data as any))

Check warning on line 34 in apps/frontend/src/components/ControlledSignatureCanvas/ControlledSignatureCanvas.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
}, [value, sigCanvas.current, doesCanvasHaveData])

/**
Expand Down Expand Up @@ -66,5 +67,5 @@
return formattedData
}

return <ReactSignatureCanvas ref={sigCanvas} />
return <ReactSignatureCanvas ref={sigCanvas} clearOnResize={false} />
}
9 changes: 8 additions & 1 deletion apps/frontend/src/components/Fields/SignatureField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const SignatureField = <T extends string>({
/>
<div className="sig-container">
{/* We need to keep changing the key to force a rerender */}
<ControlledSignatureCanvas key={hash(value || {})} value={value} />
<ControlledSignatureCanvas key={hashSignature(value)} value={value} />
<div className="sig-ctl-container">
<Button
className="sig-ctl-button doc-btn"
Expand All @@ -111,4 +111,11 @@ const SignatureField = <T extends string>({
)
}

const hashSignature = (sig: Nullish<Signature>): string => {
if (!sig)
return hash(Math.random())

return hash(JSON.stringify(sig))
}

export default SignatureField
Loading