@hubsync/esign-web-sdk 6.9.20 → 6.9.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -388,8 +388,10 @@ const VerdocsSign = class {
388
388
  utils.updateDocumentFieldValue(oldField);
389
389
  this.fieldUpdateCounter++;
390
390
  this.markEnvelopeStarted();
391
- // If a previously skipped field gets filled, remove it from the skipped list
392
- if (this.skippedFields.includes(fieldName)) {
391
+ // Only unmark as skipped when the field is actually filled with a real value.
392
+ // An empty-string save (e.g. focusout when navigating away from a skipped textbox)
393
+ // must not remove the field from skippedFields or the skip loop re-triggers.
394
+ if (this.skippedFields.includes(fieldName) && this.isFieldActuallyFilled(oldField)) {
393
395
  this.skippedFields = this.skippedFields.filter(n => n !== fieldName);
394
396
  }
395
397
  this.checkRecipientFields();
@@ -419,6 +421,12 @@ const VerdocsSign = class {
419
421
  if (field === null || field === void 0 ? void 0 : field.readonly) {
420
422
  return Promise.resolve();
421
423
  }
424
+ // Don't persist focusout-triggered saves for skipped fields — navigating away from
425
+ // a skipped textbox fires focusout with an empty value which would cause a pointless
426
+ // API call and trigger the skip loop via updateRecipientFieldValue.
427
+ if (this.skippedFields.includes(fieldName)) {
428
+ return Promise.resolve();
429
+ }
422
430
  console.log('[SIGN] saveFieldChange', fieldName, { value, prepared });
423
431
  return jsSdk.updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, fieldName, value, prepared)
424
432
  .then(updateResult => this.updateRecipientFieldValue(fieldName, updateResult))
@@ -493,7 +501,10 @@ const VerdocsSign = class {
493
501
  console.log('[SIGN] Clearing initial');
494
502
  this.initialId = null;
495
503
  const updateResult = await jsSdk.updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, field.name, null, false);
496
- return this.updateRecipientFieldValue(field.name, updateResult);
504
+ this.updateRecipientFieldValue(field.name, updateResult);
505
+ if (field.required)
506
+ this.focusFieldElement(field);
507
+ return;
497
508
  }
498
509
  // If we already have an initials block, apply it
499
510
  if (this.initialId) {
@@ -539,7 +550,10 @@ const VerdocsSign = class {
539
550
  console.log('[SIGN] Clearing signature');
540
551
  this.signatureId = null;
541
552
  const updateResult = await jsSdk.updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, field.name, null, false);
542
- return this.updateRecipientFieldValue(field.name, updateResult);
553
+ this.updateRecipientFieldValue(field.name, updateResult);
554
+ if (field.required)
555
+ this.focusFieldElement(field);
556
+ return;
543
557
  }
544
558
  // If we already have a signature block, apply it
545
559
  if (this.signatureId) {
@@ -700,6 +714,12 @@ const VerdocsSign = class {
700
714
  }
701
715
  }
702
716
  isFieldActuallyFilled(field) {
717
+ var _a;
718
+ // The server keeps value="signed" even after a signature/initial is cleared;
719
+ // settings.signature_id is the authoritative indicator of whether it's actually signed.
720
+ if (field.type === 'signature' || field.type === 'initial') {
721
+ return !!((_a = field.settings) === null || _a === void 0 ? void 0 : _a.signature_id);
722
+ }
703
723
  if (field.type === 'radio' && field.group) {
704
724
  const groupFilled = this.getRecipientFields().some(f => f.group === field.group && f.value === 'true');
705
725
  if (groupFilled) {