@everymatrix/general-registration 1.87.25 → 1.87.27

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.
@@ -8,6 +8,7 @@ export class GeneralRegistration {
8
8
  constructor() {
9
9
  this.isSelectingAddress = false;
10
10
  this.lastPostalCode = null;
11
+ this.isRestoringAfterError = false;
11
12
  this.selectedCountry = '';
12
13
  this.listOfInputValues = [];
13
14
  this.listOfInputValidity = [];
@@ -134,10 +135,12 @@ export class GeneralRegistration {
134
135
  if (value === 'GB') {
135
136
  this.selectedCountry = 'UK';
136
137
  }
137
- this.resetAllAddressFields();
138
- window.dispatchEvent(new CustomEvent('countryCodeUpdated', {
139
- detail: { name, value: this.selectedCountry }
140
- }));
138
+ if (!this.isRestoringAfterError) {
139
+ this.resetAllAddressFields();
140
+ window.dispatchEvent(new CustomEvent('countryCodeUpdated', {
141
+ detail: { name, value: this.selectedCountry }
142
+ }));
143
+ }
141
144
  }
142
145
  if (name === 'PostalCode') {
143
146
  if (!this.listOfInputs.some(i => i.name === 'CountryCode')) {
@@ -207,6 +210,10 @@ export class GeneralRegistration {
207
210
  this.isSelectingAddress = false;
208
211
  }
209
212
  handleCountryCodeUpdateGlobal(event) {
213
+ // Prevents clearing the fields when restoring after error
214
+ if (this.isRestoringAfterError) {
215
+ return;
216
+ }
210
217
  const { name } = event.detail;
211
218
  if (name === 'CountryCode') {
212
219
  const savedState = localStorage.getItem('registrationStepsState');
@@ -361,6 +368,9 @@ export class GeneralRegistration {
361
368
  }
362
369
  nextHandler(e) {
363
370
  e.preventDefault();
371
+ // Set flag before emitting values to prevent countryCodeUpdated from clearing fields
372
+ // This protects against clearing during both submission and error restoration
373
+ this.isRestoringAfterError = true;
364
374
  // Trigger events in subwidgets.
365
375
  this.emitValue = true;
366
376
  this.errorMessage = '';
@@ -661,6 +671,7 @@ export class GeneralRegistration {
661
671
  console.error(err);
662
672
  }).finally(() => {
663
673
  this.isLoadingPOST = false;
674
+ this.isRestoringAfterError = false;
664
675
  });
665
676
  }
666
677
  setRegister() {