@formio/js 5.0.0-dev.5904.e376ad2 → 5.0.0-dev.5906.c8b05b1

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.
@@ -115,13 +115,6 @@ declare class Component extends Element {
115
115
  */
116
116
  parent: Component;
117
117
  _path: string;
118
- /**
119
- * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
120
- * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
121
- * conditionallyHidden separately from "regular" visibility.
122
- */
123
- _parentConditionallyHidden: any;
124
- _conditionallyHidden: any;
125
118
  /**
126
119
  * Determines if this component is visible, or not.
127
120
  */
@@ -214,14 +207,6 @@ declare class Component extends Element {
214
207
  * @returns {boolean} - Whether the component is visible or not.
215
208
  */
216
209
  get visible(): boolean;
217
- get conditionallyHidden(): any;
218
- /**
219
- * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
220
- * @param {object} data - The data object to evaluate the condition against.
221
- * @param {object} row - The row object to evaluate the condition against.
222
- * @returns {boolean} - Whether the component is conditionally hidden.
223
- */
224
- checkConditionallyHidden(data?: object, row?: object): boolean;
225
210
  set currentForm(instance: any);
226
211
  get currentForm(): any;
227
212
  _currentForm: any;
@@ -345,18 +345,11 @@ class Component extends Element_1.default {
345
345
  this._path = '';
346
346
  // Needs for Nextgen Rules Engine
347
347
  this.resetCaches();
348
- /**
349
- * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
350
- * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
351
- * conditionallyHidden separately from "regular" visibility.
352
- */
353
- this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
354
- this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
355
348
  /**
356
349
  * Determines if this component is visible, or not.
357
350
  */
358
351
  this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
359
- this._visible = this._parentVisible && (this.hasCondition() ? !this._conditionallyHidden : !this.component.hidden);
352
+ this._visible = this._parentVisible && this.conditionallyVisible(null, data);
360
353
  this._parentDisabled = false;
361
354
  /**
362
355
  * The reference attribute name for this component
@@ -425,7 +418,7 @@ class Component extends Element_1.default {
425
418
  if (this.allowData && this.key) {
426
419
  this.options.name += `[${this.key}]`;
427
420
  // If component is visible or not set to clear on hide, set the default value.
428
- if (!(this.conditionallyHidden && this.component.clearOnHide)) {
421
+ if (this.visible || !this.component.clearOnHide) {
429
422
  if (!this.hasValue()) {
430
423
  if (this.shouldAddDefaultValue) {
431
424
  this.dataValue = this.defaultValue;
@@ -501,8 +494,7 @@ class Component extends Element_1.default {
501
494
  init() {
502
495
  var _a;
503
496
  this.disabled = this.shouldDisabled;
504
- this._conditionallyHidden = this.checkConditionallyHidden();
505
- this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
497
+ this._visible = this.conditionallyVisible(null, null);
506
498
  if ((_a = this.component.addons) === null || _a === void 0 ? void 0 : _a.length) {
507
499
  this.component.addons.forEach((addon) => this.createAddon(addon));
508
500
  }
@@ -621,6 +613,7 @@ class Component extends Element_1.default {
621
613
  return;
622
614
  }
623
615
  this._visible = value;
616
+ this.clearOnHide();
624
617
  this.redraw();
625
618
  }
626
619
  }
@@ -641,21 +634,6 @@ class Component extends Element_1.default {
641
634
  }
642
635
  return this._visible && this._parentVisible;
643
636
  }
644
- get conditionallyHidden() {
645
- return this._conditionallyHidden || this._parentConditionallyHidden;
646
- }
647
- /**
648
- * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
649
- * @param {object} data - The data object to evaluate the condition against.
650
- * @param {object} row - The row object to evaluate the condition against.
651
- * @returns {boolean} - Whether the component is conditionally hidden.
652
- */
653
- checkConditionallyHidden(data = null, row = null) {
654
- if (!this.hasCondition()) {
655
- return false;
656
- }
657
- return !this.conditionallyVisible(data, row);
658
- }
659
637
  get currentForm() {
660
638
  return this._currentForm;
661
639
  }
@@ -1823,7 +1801,7 @@ class Component extends Element_1.default {
1823
1801
  rebuild() {
1824
1802
  this.destroy();
1825
1803
  this.init();
1826
- this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
1804
+ this.visible = this.conditionallyVisible(null, null);
1827
1805
  return this.redraw();
1828
1806
  }
1829
1807
  /**
@@ -1890,8 +1868,8 @@ class Component extends Element_1.default {
1890
1868
  conditionallyVisible(data, row) {
1891
1869
  data = data || this.rootValue;
1892
1870
  row = row || this.data;
1893
- if (this.builderMode || this.previewMode) {
1894
- return true;
1871
+ if (this.builderMode || this.previewMode || !this.hasCondition()) {
1872
+ return !this.component.hidden;
1895
1873
  }
1896
1874
  data = data || (this.root ? this.root.data : {});
1897
1875
  return this.checkCondition(row, data);
@@ -1921,14 +1899,8 @@ class Component extends Element_1.default {
1921
1899
  if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
1922
1900
  this.redraw();
1923
1901
  }
1924
- // Check advanced conditions (and cache the result)
1925
- const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1926
- if (isConditionallyHidden !== this._conditionallyHidden) {
1927
- this._conditionallyHidden = isConditionallyHidden;
1928
- this.clearOnHide();
1929
- }
1930
- // Check visibility
1931
- const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1902
+ // Check advanced conditions
1903
+ const visible = this.conditionallyVisible(data, row);
1932
1904
  if (this.visible !== visible) {
1933
1905
  this.visible = visible;
1934
1906
  }
@@ -2038,12 +2010,6 @@ class Component extends Element_1.default {
2038
2010
  FormioUtils.setActionProperty(newComponent, action, result, row, data, this);
2039
2011
  const property = action.property.value;
2040
2012
  if (!lodash_1.default.isEqual(lodash_1.default.get(this.component, property), lodash_1.default.get(newComponent, property))) {
2041
- // Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
2042
- // separately from the component's hidden property, and technically this Advanced Logic conditionally hides
2043
- // a component, we need to set _conditionallyHidden to the new value
2044
- if (property === 'hidden') {
2045
- this._conditionallyHidden = newComponent.hidden;
2046
- }
2047
2013
  changed = true;
2048
2014
  }
2049
2015
  break;
@@ -2057,7 +2023,7 @@ class Component extends Element_1.default {
2057
2023
  component: newComponent,
2058
2024
  result,
2059
2025
  });
2060
- if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
2026
+ if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2061
2027
  this.setValue(newValue);
2062
2028
  if (this.viewOnly) {
2063
2029
  this.dataValue = newValue;
@@ -2090,7 +2056,7 @@ class Component extends Element_1.default {
2090
2056
  component: newComponent,
2091
2057
  result,
2092
2058
  }, 'value');
2093
- if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
2059
+ if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2094
2060
  this.setValue(newValue);
2095
2061
  if (this.viewOnly) {
2096
2062
  this.dataValue = newValue;
@@ -2201,7 +2167,7 @@ class Component extends Element_1.default {
2201
2167
  this.component.clearOnHide !== false &&
2202
2168
  !this.options.readOnly &&
2203
2169
  !this.options.showHiddenFields) {
2204
- if (this.conditionallyHidden) {
2170
+ if (!this.visible) {
2205
2171
  this.deleteValue();
2206
2172
  }
2207
2173
  else if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2460,7 +2426,7 @@ class Component extends Element_1.default {
2460
2426
  */
2461
2427
  get dataValue() {
2462
2428
  if (!this.key ||
2463
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2429
+ (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2464
2430
  return this.emptyValue;
2465
2431
  }
2466
2432
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2479,7 +2445,7 @@ class Component extends Element_1.default {
2479
2445
  set dataValue(value) {
2480
2446
  if (!this.allowData ||
2481
2447
  !this.key ||
2482
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2448
+ (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2483
2449
  return;
2484
2450
  }
2485
2451
  if ((value !== null) && (value !== undefined)) {
@@ -2800,7 +2766,7 @@ class Component extends Element_1.default {
2800
2766
  // If no calculated value or
2801
2767
  // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
2802
2768
  const { clearOnHide } = this.component;
2803
- const shouldBeCleared = this.conditionallyHidden && clearOnHide;
2769
+ const shouldBeCleared = !this.visible && clearOnHide;
2804
2770
  const allowOverride = lodash_1.default.get(this.component, 'allowCalculateOverride', false);
2805
2771
  if (shouldBeCleared) {
2806
2772
  // remove calculated value so that the value is recalculated once component becomes visible
@@ -3298,6 +3264,7 @@ class Component extends Element_1.default {
3298
3264
  // Force valid if component is hidden.
3299
3265
  () => {
3300
3266
  if (!this.component.validateWhenHidden && (!this.visible || !this.checkCondition(row, data))) {
3267
+ // If this component is forced valid when it is hidden, then we also need to reset the errors for this component.
3301
3268
  this._errors = [];
3302
3269
  return true;
3303
3270
  }
@@ -3439,7 +3406,7 @@ class Component extends Element_1.default {
3439
3406
  // If component definition changed, replace it.
3440
3407
  if (!lodash_1.default.isEqual(this.component, newComponent)) {
3441
3408
  this.component = newComponent;
3442
- const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
3409
+ const visible = this.conditionallyVisible(null, null);
3443
3410
  const disabled = this.shouldDisabled;
3444
3411
  // Change states which won't be recalculated during redrawing
3445
3412
  if (this.visible !== visible) {
@@ -133,10 +133,10 @@ exports.default = [
133
133
  {
134
134
  weight: 700,
135
135
  type: 'checkbox',
136
- label: 'Omit Value From Submission Data When Conditionally Hidden',
136
+ label: 'Clear Value When Hidden',
137
137
  key: 'clearOnHide',
138
138
  defaultValue: true,
139
- tooltip: 'When a field is conditionally hidden, omit the value from the submission data.',
139
+ tooltip: 'When a field is hidden, clear the value.',
140
140
  input: true
141
141
  },
142
142
  utils_1.default.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
@@ -84,26 +84,17 @@ class NestedComponent extends Field_1.default {
84
84
  const visibilityChanged = this._visible !== value;
85
85
  this._visible = value;
86
86
  const isVisible = this.visible;
87
- const isConditionallyHidden = this.checkConditionallyHidden();
88
87
  const forceShow = this.shouldForceShow();
89
88
  const forceHide = this.shouldForceHide();
90
- this.components.forEach((component) => {
89
+ this.components.forEach(component => {
91
90
  // Set the parent visibility first since we may have nested components within nested components
92
91
  // and they need to be able to determine their visibility based on the parent visibility.
93
92
  component.parentVisible = isVisible;
94
- component._parentConditionallyHidden = isConditionallyHidden;
95
- let visible;
96
- if (component.hasCondition()) {
97
- component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
98
- visible = !component.conditionallyHidden;
99
- }
100
- else {
101
- visible = !component.component.hidden;
102
- }
103
- if (forceShow || visible) {
93
+ const conditionallyVisible = component.conditionallyVisible();
94
+ if (forceShow || conditionallyVisible) {
104
95
  component.visible = true;
105
96
  }
106
- else if (forceHide || !isVisible || !visible) {
97
+ else if (forceHide || !isVisible || !conditionallyVisible) {
107
98
  component.visible = false;
108
99
  }
109
100
  // If hiding a nested component, clear all errors below.
@@ -112,6 +103,7 @@ class NestedComponent extends Field_1.default {
112
103
  }
113
104
  });
114
105
  if (visibilityChanged) {
106
+ this.clearOnHide();
115
107
  this.redraw();
116
108
  }
117
109
  }
@@ -392,7 +384,6 @@ class NestedComponent extends Field_1.default {
392
384
  data = data || this.data;
393
385
  options.parent = this;
394
386
  options.parentVisible = this.visible;
395
- options.parentConditionallyHidden = this.conditionallyHidden;
396
387
  options.root = (options === null || options === void 0 ? void 0 : options.root) || this.root || this;
397
388
  options.localRoot = this.localRoot;
398
389
  options.skipInit = true;
@@ -651,7 +642,7 @@ class NestedComponent extends Field_1.default {
651
642
  clearOnHide(show) {
652
643
  super.clearOnHide(show);
653
644
  if (this.component.clearOnHide) {
654
- if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
645
+ if (this.allowData && !this.hasValue() && !(this.options.server && !this.visible)) {
655
646
  this.dataValue = this.defaultValue;
656
647
  }
657
648
  if (this.hasValue()) {
@@ -680,7 +671,7 @@ class NestedComponent extends Field_1.default {
680
671
  }
681
672
  calculateValue(data, flags, row) {
682
673
  // Do not iterate into children and calculateValues if this nested component is conditionally hidden.
683
- if (this.conditionallyHidden) {
674
+ if (!this.conditionallyVisible()) {
684
675
  return false;
685
676
  }
686
677
  return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
@@ -75,7 +75,7 @@ class DataMapComponent extends DataGrid_1.default {
75
75
  }
76
76
  get dataValue() {
77
77
  if (!this.key ||
78
- (this.conditionallyHidden && this.component.clearOnHide)) {
78
+ (!this.visible && this.component.clearOnHide)) {
79
79
  return this.emptyValue;
80
80
  }
81
81
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -1151,7 +1151,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1151
1151
  }
1152
1152
  }
1153
1153
  const changed = this.hasChanged(value, this.dataValue);
1154
- if (this.parent) {
1154
+ if (this.parent && !this.options.server) {
1155
1155
  this.parent.checkComponentConditions();
1156
1156
  }
1157
1157
  this.dataValue = value;
@@ -1184,7 +1184,10 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1184
1184
  this.editRows = this.editRows.slice(0, dataLength);
1185
1185
  this.openWhenEmpty();
1186
1186
  this.updateOnChange(flags, changed);
1187
- this.checkData();
1187
+ // do not call checkData with server option, it is called when change is triggered in updateOnChange
1188
+ if (!this.options.server) {
1189
+ this.checkData();
1190
+ }
1188
1191
  this.changeState(changed, flags);
1189
1192
  return changed;
1190
1193
  }
@@ -421,10 +421,10 @@ class FormComponent extends Component_1.default {
421
421
  return this.subFormReady;
422
422
  }
423
423
  hideSubmitButton(component) {
424
- const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
424
+ const isSubmitButton = (component.type === 'button') &&
425
+ ((component.action === 'submit') || !component.action);
425
426
  if (isSubmitButton) {
426
427
  component.hidden = true;
427
- component.customConditional = 'show = false';
428
428
  }
429
429
  }
430
430
  /**
@@ -434,7 +434,7 @@ class FormComponent extends Component_1.default {
434
434
  */
435
435
  loadSubForm(fromAttach) {
436
436
  var _a, _b, _c, _d, _e;
437
- if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
437
+ if (this.builderMode || this.isHidden() || (this.isSubFormLazyLoad() && !fromAttach)) {
438
438
  return Promise.resolve();
439
439
  }
440
440
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -518,7 +518,7 @@ class FormComponent extends Component_1.default {
518
518
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
519
519
  */
520
520
  get shouldSubmit() {
521
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
521
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.isHidden();
522
522
  }
523
523
  /**
524
524
  * Returns the data for the subform.
@@ -56,21 +56,9 @@ class HTMLComponent extends Component_1.default {
56
56
  }
57
57
  checkRefreshOn(changed) {
58
58
  super.checkRefreshOn(changed);
59
- let visible;
60
- if (this.hasCondition()) {
61
- this._conditionallyHidden = this.checkConditionallyHidden();
62
- visible = !this.conditionallyHidden;
63
- }
64
- else {
65
- visible = !this.component.hidden;
66
- }
67
- const shouldSetContent = !this.builderMode
68
- && this.component.refreshOnChange
69
- && this.element
70
- && !lodash_1.default.isUndefined(changed)
71
- && ((lodash_1.default.isBoolean(changed) && changed) || !lodash_1.default.isEmpty(changed))
72
- && visible;
73
- if (shouldSetContent) {
59
+ if (!this.builderMode && this.component.refreshOnChange && this.element &&
60
+ !lodash_1.default.isUndefined(changed) && ((lodash_1.default.isBoolean(changed) && changed) || !lodash_1.default.isEmpty(changed)) &&
61
+ this.conditionallyVisible(this.data, this.row)) {
74
62
  this.setContent(this.element, this.renderContent());
75
63
  }
76
64
  }
@@ -115,13 +115,6 @@ declare class Component extends Element {
115
115
  */
116
116
  parent: Component;
117
117
  _path: string;
118
- /**
119
- * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
120
- * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
121
- * conditionallyHidden separately from "regular" visibility.
122
- */
123
- _parentConditionallyHidden: any;
124
- _conditionallyHidden: any;
125
118
  /**
126
119
  * Determines if this component is visible, or not.
127
120
  */
@@ -214,14 +207,6 @@ declare class Component extends Element {
214
207
  * @returns {boolean} - Whether the component is visible or not.
215
208
  */
216
209
  get visible(): boolean;
217
- get conditionallyHidden(): any;
218
- /**
219
- * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
220
- * @param {object} data - The data object to evaluate the condition against.
221
- * @param {object} row - The row object to evaluate the condition against.
222
- * @returns {boolean} - Whether the component is conditionally hidden.
223
- */
224
- checkConditionallyHidden(data?: object, row?: object): boolean;
225
210
  set currentForm(instance: any);
226
211
  get currentForm(): any;
227
212
  _currentForm: any;
@@ -308,18 +308,11 @@ export default class Component extends Element {
308
308
  this._path = '';
309
309
  // Needs for Nextgen Rules Engine
310
310
  this.resetCaches();
311
- /**
312
- * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
313
- * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
314
- * conditionallyHidden separately from "regular" visibility.
315
- */
316
- this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
317
- this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
318
311
  /**
319
312
  * Determines if this component is visible, or not.
320
313
  */
321
314
  this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
322
- this._visible = this._parentVisible && (this.hasCondition() ? !this._conditionallyHidden : !this.component.hidden);
315
+ this._visible = this._parentVisible && this.conditionallyVisible(null, data);
323
316
  this._parentDisabled = false;
324
317
  /**
325
318
  * The reference attribute name for this component
@@ -388,7 +381,7 @@ export default class Component extends Element {
388
381
  if (this.allowData && this.key) {
389
382
  this.options.name += `[${this.key}]`;
390
383
  // If component is visible or not set to clear on hide, set the default value.
391
- if (!(this.conditionallyHidden && this.component.clearOnHide)) {
384
+ if (this.visible || !this.component.clearOnHide) {
392
385
  if (!this.hasValue()) {
393
386
  if (this.shouldAddDefaultValue) {
394
387
  this.dataValue = this.defaultValue;
@@ -462,8 +455,7 @@ export default class Component extends Element {
462
455
  }
463
456
  init() {
464
457
  this.disabled = this.shouldDisabled;
465
- this._conditionallyHidden = this.checkConditionallyHidden();
466
- this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
458
+ this._visible = this.conditionallyVisible(null, null);
467
459
  if (this.component.addons?.length) {
468
460
  this.component.addons.forEach((addon) => this.createAddon(addon));
469
461
  }
@@ -581,6 +573,7 @@ export default class Component extends Element {
581
573
  return;
582
574
  }
583
575
  this._visible = value;
576
+ this.clearOnHide();
584
577
  this.redraw();
585
578
  }
586
579
  }
@@ -601,21 +594,6 @@ export default class Component extends Element {
601
594
  }
602
595
  return this._visible && this._parentVisible;
603
596
  }
604
- get conditionallyHidden() {
605
- return this._conditionallyHidden || this._parentConditionallyHidden;
606
- }
607
- /**
608
- * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
609
- * @param {object} data - The data object to evaluate the condition against.
610
- * @param {object} row - The row object to evaluate the condition against.
611
- * @returns {boolean} - Whether the component is conditionally hidden.
612
- */
613
- checkConditionallyHidden(data = null, row = null) {
614
- if (!this.hasCondition()) {
615
- return false;
616
- }
617
- return !this.conditionallyVisible(data, row);
618
- }
619
597
  get currentForm() {
620
598
  return this._currentForm;
621
599
  }
@@ -1786,7 +1764,7 @@ export default class Component extends Element {
1786
1764
  rebuild() {
1787
1765
  this.destroy();
1788
1766
  this.init();
1789
- this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
1767
+ this.visible = this.conditionallyVisible(null, null);
1790
1768
  return this.redraw();
1791
1769
  }
1792
1770
  /**
@@ -1853,8 +1831,8 @@ export default class Component extends Element {
1853
1831
  conditionallyVisible(data, row) {
1854
1832
  data = data || this.rootValue;
1855
1833
  row = row || this.data;
1856
- if (this.builderMode || this.previewMode) {
1857
- return true;
1834
+ if (this.builderMode || this.previewMode || !this.hasCondition()) {
1835
+ return !this.component.hidden;
1858
1836
  }
1859
1837
  data = data || (this.root ? this.root.data : {});
1860
1838
  return this.checkCondition(row, data);
@@ -1884,14 +1862,8 @@ export default class Component extends Element {
1884
1862
  if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
1885
1863
  this.redraw();
1886
1864
  }
1887
- // Check advanced conditions (and cache the result)
1888
- const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1889
- if (isConditionallyHidden !== this._conditionallyHidden) {
1890
- this._conditionallyHidden = isConditionallyHidden;
1891
- this.clearOnHide();
1892
- }
1893
- // Check visibility
1894
- const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1865
+ // Check advanced conditions
1866
+ const visible = this.conditionallyVisible(data, row);
1895
1867
  if (this.visible !== visible) {
1896
1868
  this.visible = visible;
1897
1869
  }
@@ -2001,12 +1973,6 @@ export default class Component extends Element {
2001
1973
  FormioUtils.setActionProperty(newComponent, action, result, row, data, this);
2002
1974
  const property = action.property.value;
2003
1975
  if (!_.isEqual(_.get(this.component, property), _.get(newComponent, property))) {
2004
- // Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
2005
- // separately from the component's hidden property, and technically this Advanced Logic conditionally hides
2006
- // a component, we need to set _conditionallyHidden to the new value
2007
- if (property === 'hidden') {
2008
- this._conditionallyHidden = newComponent.hidden;
2009
- }
2010
1976
  changed = true;
2011
1977
  }
2012
1978
  break;
@@ -2020,7 +1986,7 @@ export default class Component extends Element {
2020
1986
  component: newComponent,
2021
1987
  result,
2022
1988
  });
2023
- if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
1989
+ if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2024
1990
  this.setValue(newValue);
2025
1991
  if (this.viewOnly) {
2026
1992
  this.dataValue = newValue;
@@ -2053,7 +2019,7 @@ export default class Component extends Element {
2053
2019
  component: newComponent,
2054
2020
  result,
2055
2021
  }, 'value');
2056
- if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
2022
+ if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2057
2023
  this.setValue(newValue);
2058
2024
  if (this.viewOnly) {
2059
2025
  this.dataValue = newValue;
@@ -2164,7 +2130,7 @@ export default class Component extends Element {
2164
2130
  this.component.clearOnHide !== false &&
2165
2131
  !this.options.readOnly &&
2166
2132
  !this.options.showHiddenFields) {
2167
- if (this.conditionallyHidden) {
2133
+ if (!this.visible) {
2168
2134
  this.deleteValue();
2169
2135
  }
2170
2136
  else if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2426,7 +2392,7 @@ export default class Component extends Element {
2426
2392
  */
2427
2393
  get dataValue() {
2428
2394
  if (!this.key ||
2429
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2395
+ (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2430
2396
  return this.emptyValue;
2431
2397
  }
2432
2398
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2445,7 +2411,7 @@ export default class Component extends Element {
2445
2411
  set dataValue(value) {
2446
2412
  if (!this.allowData ||
2447
2413
  !this.key ||
2448
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2414
+ (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2449
2415
  return;
2450
2416
  }
2451
2417
  if ((value !== null) && (value !== undefined)) {
@@ -2765,7 +2731,7 @@ export default class Component extends Element {
2765
2731
  // If no calculated value or
2766
2732
  // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
2767
2733
  const { clearOnHide } = this.component;
2768
- const shouldBeCleared = this.conditionallyHidden && clearOnHide;
2734
+ const shouldBeCleared = !this.visible && clearOnHide;
2769
2735
  const allowOverride = _.get(this.component, 'allowCalculateOverride', false);
2770
2736
  if (shouldBeCleared) {
2771
2737
  // remove calculated value so that the value is recalculated once component becomes visible
@@ -3260,6 +3226,7 @@ export default class Component extends Element {
3260
3226
  // Force valid if component is hidden.
3261
3227
  () => {
3262
3228
  if (!this.component.validateWhenHidden && (!this.visible || !this.checkCondition(row, data))) {
3229
+ // If this component is forced valid when it is hidden, then we also need to reset the errors for this component.
3263
3230
  this._errors = [];
3264
3231
  return true;
3265
3232
  }
@@ -3401,7 +3368,7 @@ export default class Component extends Element {
3401
3368
  // If component definition changed, replace it.
3402
3369
  if (!_.isEqual(this.component, newComponent)) {
3403
3370
  this.component = newComponent;
3404
- const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
3371
+ const visible = this.conditionallyVisible(null, null);
3405
3372
  const disabled = this.shouldDisabled;
3406
3373
  // Change states which won't be recalculated during redrawing
3407
3374
  if (this.visible !== visible) {
@@ -128,10 +128,10 @@ export default [
128
128
  {
129
129
  weight: 700,
130
130
  type: 'checkbox',
131
- label: 'Omit Value From Submission Data When Conditionally Hidden',
131
+ label: 'Clear Value When Hidden',
132
132
  key: 'clearOnHide',
133
133
  defaultValue: true,
134
- tooltip: 'When a field is conditionally hidden, omit the value from the submission data.',
134
+ tooltip: 'When a field is hidden, clear the value.',
135
135
  input: true
136
136
  },
137
137
  EditFormUtils.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),