Skip to content

Commit 8f59272

Browse files
authored
Merge pull request #300 from rvsia/nestedCondition
fix(renderer): fix conditions for nested names
2 parents 3354777 + 7610a2a commit 8f59272

File tree

4 files changed

+116
-2406
lines changed

4 files changed

+116
-2406
lines changed

packages/pf4-component-mapper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
},
8787
"peerDependencies": {
8888
"@data-driven-forms/react-form-renderer": "^1.11.0",
89-
"@patternfly/react-core": "^3.104.0"
89+
"@patternfly/react-core": "^3.134.2"
9090
},
9191
"dependencies": {
9292
"@patternfly/patternfly-next": "^1.0.175",

packages/react-form-renderer/src/form-renderer/condition.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { isEmpty as lodashIsEmpty } from 'lodash';
3+
import lodashIsEmpty from 'lodash/isEmpty';
44
import { FormSpy } from 'react-final-form';
5+
import get from 'lodash/get';
56

67
const isEmptyValue = (value) => typeof value === 'number' || value === true ? false : lodashIsEmpty(value);
78

@@ -26,11 +27,11 @@ const Condition = ({ condition, children }) => {
2627

2728
const shouldRender = (values, conditionItem) => {
2829
if (typeof conditionItem.when === 'string') {
29-
return fieldCondition(values[conditionItem.when], conditionItem);
30+
return fieldCondition(get(values, conditionItem.when), conditionItem);
3031
}
3132

3233
if (Array.isArray(conditionItem.when)) {
33-
return conditionItem.when.map(fieldName => fieldCondition(values[fieldName], conditionItem)).find(condition => !!condition);
34+
return conditionItem.when.map(fieldName => fieldCondition(get(values, fieldName), conditionItem)).find(condition => !!condition);
3435
}
3536

3637
return false;

0 commit comments

Comments
 (0)