Skip to content

Open-source document signature platform. Not affiliated with DocuSign.

TypeScript

Clear a box-full warning when its check can't be made

Claudec0012a68b6c5
diff --git a/src/components/signing/signing-live-shell.tsx b/src/components/signing/signing-live-shell.tsx
index bbf6a5e..0efa437 100644
--- a/src/components/signing/signing-live-shell.tsx
+++ b/src/components/signing/signing-live-shell.tsx
@@ -650,6 +650,21 @@ export function SigningLiveShell({
continue;
}
+ const isStillCurrent = () =>
+ (latestTextValuesRef.current[field.id] ?? "").trim() === value;
+ // A check that could not be made leaves no warning, so it never
+ // keeps Finish off: signing makes the same check when they finish.
+ // The answer is checked again the next time it changes.
+ const giveUp = () => {
+ if (checkedAnswersRef.current[field.id] === value) {
+ delete checkedAnswersRef.current[field.id];
+ }
+
+ if (isStillCurrent()) {
+ setTooLongAnswers((current) => withoutKey(current, field.id));
+ }
+ };
+
void fetch(record.fieldFitUrl, {
body: JSON.stringify({ fieldId: field.id, value }),
headers: { "content-type": "application/json" },
@@ -661,12 +676,13 @@ export function SigningLiveShell({
maxCharacters?: number;
} | null;
+ if (!response.ok || !payload) {
+ giveUp();
+ return;
+ }
+
// An answer changed since is checked again on its own.
- if (
- !response.ok ||
- !payload ||
- (latestTextValuesRef.current[field.id] ?? "").trim() !== value
- ) {
+ if (!isStillCurrent()) {
return;
}
@@ -677,9 +693,7 @@ export function SigningLiveShell({
: withoutKey(current, field.id),
);
})
- .catch(() => {
- // Signing checks it again when the signer finishes.
- });
+ .catch(giveUp);
}
}, 400);