@ukhomeoffice/cop-react-form-renderer 4.30.0 → 4.32.0

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.
@@ -73,13 +73,14 @@ var FormPage = function FormPage(_ref) {
73
73
  _useState4 = _slicedToArray(_useState3, 2),
74
74
  patchLabel = _useState4[0],
75
75
  setPatchLabel = _useState4[1];
76
+
77
+ var docTitle = (0, _react.useState)(document.title);
76
78
  /**
77
79
  * Handle the state of the data directly within the page.
78
80
  * This is so that the overall form data isn't affected until such
79
81
  * time as the onAction handler is invoked.
80
82
  */
81
83
 
82
-
83
84
  var onPageChange = function onPageChange(_ref2) {
84
85
  var target = _ref2.target;
85
86
  page.formData[target.name] = target.value;
@@ -91,6 +92,10 @@ var FormPage = function FormPage(_ref) {
91
92
  });
92
93
  };
93
94
 
95
+ (0, _react.useEffect)(function () {
96
+ document.title = errors.length > 0 ? 'Error: ' + docTitle : docTitle;
97
+ }, [errors, docTitle]);
98
+
94
99
  var classes = _utils.default.classBuilder(classBlock, classModifiers, className);
95
100
 
96
101
  page.actions = (_page$actions = page.actions) === null || _page$actions === void 0 ? void 0 : _page$actions.map(function (action) {
@@ -292,9 +292,10 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
292
292
  }, [currentTask.fullPages, data, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.sections, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.nonSequential]);
293
293
 
294
294
  var onPageChange = function onPageChange(newPageId) {
295
+ var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
295
296
  clearErrors();
296
297
  setPageId(newPageId);
297
- hooks.onPageChange(newPageId);
298
+ hooks.onPageChange(newPageId, state);
298
299
  };
299
300
 
300
301
  (0, _react.useEffect)(function () {
@@ -28,7 +28,7 @@ var validateEmail = function validateEmail(value) {
28
28
 
29
29
  if (typeof value === 'string') {
30
30
  // The following is an interim fix pending a mechanism for validating against specific values
31
- if (['Line manager email', 'Delegate email address'].includes(label) && value === userEmail) {
31
+ if (['Line manager email', 'Delegate email address'].includes(label) && value.toLowerCase() === userEmail) {
32
32
  return "".concat(label, " cannot be the same as the user email address");
33
33
  }
34
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.30.0",
3
+ "version": "4.32.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",