Skip to content

Commit

Permalink
Fix empty dxForm item if it has multiple nested config-components (#326
Browse files Browse the repository at this point in the history
…) (#328)
  • Loading branch information
ovchinnikov authored Mar 26, 2019
1 parent 769c7f7 commit 01d82bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/core/__tests__/template.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ describe("component/render in nested options", () => {

<CollectionNestedComponent/>

<CollectionNestedComponent>
<CollectionNestedComponent/>
<CollectionNestedComponent/>
</CollectionNestedComponent>
</TestComponent>
);

Expand All @@ -543,6 +547,7 @@ describe("component/render in nested options", () => {
expect(options["collection[3].template"]).toBe("collection[3].template");
expect(options["collection[4].template"]).toBe(undefined);
expect(options["collection[5].template"]).toBe(undefined);
expect(options["collection[6].template"]).toBe(undefined);
expect(options["option.item"]).toBe(undefined);
expect(options["option.template"]).toBe(undefined);

Expand Down
6 changes: 5 additions & 1 deletion src/core/options-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,13 @@ class OptionsManager {
);

const nestedObjects = this._getNestedOptionsObjects(e.children, templateRegistrationRequired);
const nestedObjectsCount = Object.keys(nestedObjects).reduce((acc, item) => {
const obj = nestedObjects[item];
return acc + (Array.isArray(obj) ? obj.length : 1);
}, 0);

const hasChildrenForTemplate =
ReactChildren.count(e.element.props.children) > Object.keys(nestedObjects).length;
ReactChildren.count(e.element.props.children) > nestedObjectsCount;

if (templateRegistrationRequired) {
this._templateHost.add({
Expand Down

0 comments on commit 01d82bf

Please sign in to comment.