@4site/engrid-scripts 0.22.0 → 0.22.2

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.
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AppVersion = "0.22.0";
1
+ export declare const AppVersion = "0.22.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const AppVersion = "0.22.0";
1
+ export const AppVersion = "0.22.2";
@@ -12,4 +12,5 @@ export declare class WelcomeBack {
12
12
  private addPersonalDetailsSummary;
13
13
  private addEventListeners;
14
14
  enOnValidate(): void;
15
+ doubleCheckValidation(): void;
15
16
  }
@@ -129,16 +129,39 @@ export class WelcomeBack {
129
129
  });
130
130
  });
131
131
  this._form.onValidate.subscribe(this.enOnValidate.bind(this));
132
+ this._form.onValidate.subscribe(() => {
133
+ window.setTimeout(this.doubleCheckValidation.bind(this), 150);
134
+ });
132
135
  }
133
136
  enOnValidate() {
134
- if (!this._form.validate)
137
+ if (!this._form.validate) {
138
+ // Disable the fast personal details if the form is invalidated by other components running before
139
+ ENGrid.setBodyData("hide-fast-personal-details", false);
135
140
  return;
136
- const regionFieldValue = ENGrid.getFieldValue("supporter.region");
141
+ }
142
+ const regionField = ENGrid.getField("supporter.region");
143
+ const regionFieldValue = regionField ? regionField.value : "";
144
+ const regionFieldType = regionField === null || regionField === void 0 ? void 0 : regionField.tagName.toLowerCase();
137
145
  const regionFieldLabel = document.querySelector(".en__field--region label");
138
- if (regionFieldLabel && regionFieldValue === "") {
146
+ if (regionFieldType === "select" &&
147
+ regionFieldLabel &&
148
+ regionFieldValue === "") {
139
149
  ENGrid.setError(".en__field--region", `${regionFieldLabel.innerText} is required`);
140
150
  ENGrid.setBodyData("hide-fast-personal-details", false);
141
151
  this._form.validate = false;
142
152
  }
143
153
  }
154
+ doubleCheckValidation() {
155
+ // Disable the fast personal details if the form is invalidated by other components running AFTER
156
+ // the fast personal details component
157
+ const validationError = document.querySelector(".fast-personal-details .en__field--validationFailed");
158
+ if (validationError) {
159
+ ENGrid.setBodyData("hide-fast-personal-details", false);
160
+ validationError.scrollIntoView({
161
+ behavior: "smooth",
162
+ block: "center",
163
+ });
164
+ }
165
+ return;
166
+ }
144
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4site/engrid-scripts",
3
- "version": "0.22.0",
3
+ "version": "0.22.2",
4
4
  "description": "Scripts for the ENGRID Project",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "strongly-typed-events": "^2.0.9"
26
26
  },
27
27
  "homepage": "https://github.com/4site-interactive-studios/engrid#readme",
28
- "gitHead": "e5d7823be14fd1c1116bd43d80be85da4c1e69fd",
28
+ "gitHead": "fab50c9fa377f36deec8f098075591d55a7c5e2f",
29
29
  "devDependencies": {
30
30
  "nodemon": "^2.0.20"
31
31
  }