Skip to content

Commit

Permalink
Fix path prop usage of DispatchField
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarmueller committed Feb 18, 2019
1 parent 32c5986 commit b212178
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/util/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
THE SOFTWARE.
*/
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import has from 'lodash/has';
import cloneDeep from 'lodash/cloneDeep';
import merge from 'lodash/merge';
Expand Down Expand Up @@ -461,7 +462,7 @@ export const mapDispatchToArrayControlProps = (
addItem: (path: string, value: any) => () => {
dispatch(
update(path, array => {
if (array === undefined || array === null) {
if (isEmpty(array)) {
return [value];
}

Expand Down
6 changes: 4 additions & 2 deletions packages/material/src/complex/MaterialTableControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ const NonEmptyCell = ({
scopedSchema,
errors
}: NonEmptyCellProps) => {
const path = rowPath + (scopedSchema.type === 'object' ? '.' + propName : '');
console.log('path', path);
const errorsPerEntry: any[] = filter(
errors,
error => error.dataPath === rowPath + '.' + propName
error => error.dataPath === path
).map(e => e.message);
const isValid = isEmpty(errorsPerEntry);
return (
Expand All @@ -155,7 +157,7 @@ const NonEmptyCell = ({
undefined,
scopedSchema.type === 'object' ? `#/properties/${propName}` : '#'
)}
path={rowPath}
path={path}
/>
<FormHelperText error={!isValid}>
{!isValid && formatErrorMessage(errorsPerEntry)}
Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla/src/complex/TableArrayControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class TableArrayControl extends React.Component<
<DispatchField
schema={schema}
uischema={createControlElement(prop)}
path={childPath}
path={childPath + '.' + prop}
/>
</td>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/vanilla/src/controls/InputControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class InputControl extends Control<
schema,
visible,
required,
parentPath,
path,
fields
} = this.props;

Expand Down Expand Up @@ -93,7 +93,7 @@ export class InputControl extends Control<
<DispatchField
uischema={uischema}
schema={schema}
path={parentPath}
path={path}
id={id + '-input'}
/>
<div className={divClassNames}>
Expand Down

0 comments on commit b212178

Please sign in to comment.