@ukhomeoffice/cop-react-form-renderer 5.49.3-alpha → 5.49.4

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.
@@ -15,7 +15,7 @@ var getPageTitle = function getPageTitle(title, formData) {
15
15
  if (typeof title === 'string') {
16
16
  return _copReactComponents.Utils.interpolateString(title, formData);
17
17
  }
18
- if (!Array.isArray(title)) {
18
+ if (!Array.isArray(title) || Object.keys(formData).length === 0) {
19
19
  return null;
20
20
  }
21
21
  var shownOption = title.find(function (option) {
@@ -113,4 +113,26 @@ describe('utils.FormPage.getPageTitle', function () {
113
113
  var result = (0, _getPageTitle.default)(PAGE.title, FORM_DATA);
114
114
  expect(result).toEqual("".concat(FORM_DATA.testField, " title"));
115
115
  });
116
+ it('should return null for a conditional title if formData is empty', function () {
117
+ var PAGE = {
118
+ title: [{
119
+ title: 'First title',
120
+ show_when: [{
121
+ field: 'testField2',
122
+ op: '=',
123
+ value: 'no'
124
+ }]
125
+ }, {
126
+ // eslint-disable-next-line no-template-curly-in-string
127
+ title: '${testField} title',
128
+ show_when: [{
129
+ field: 'testField2',
130
+ op: '=',
131
+ value: 'yes'
132
+ }]
133
+ }]
134
+ };
135
+ var result = (0, _getPageTitle.default)(PAGE.title, {});
136
+ expect(result).toEqual(null);
137
+ });
116
138
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.49.3-alpha",
3
+ "version": "5.49.4",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",