Skip to content

Commit abdce80

Browse files
wip. fix DXO- nesteds
1 parent 56618cd commit abdce80

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/devextreme-angular/src/core/component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export abstract class DxComponent implements OnChanges, OnInit, DoCheck, AfterCo
6969
protected _optionsToUpdate: any = {};
7070

7171
private readonly _collectionContainerImpl: ICollectionNestedOptionContainer;
72+
73+
private _currentNestedOptions:Map<string, any> = new Map();
7274

7375
@ContentChildren(NESTED_ITEM_TOKEN)
7476
set _nestedItems(value: QueryList<{ propertyName: string; className: string; component: ICollectionNestedOption }>) {
@@ -78,6 +80,7 @@ export abstract class DxComponent implements OnChanges, OnInit, DoCheck, AfterCo
7880
{
7981
componentClassName: this.constructor.name,
8082
legacyClassNames: this.getLegacyClassNames(),
83+
currentOptions: this._currentNestedOptions
8184
},
8285
);
8386
}

packages/devextreme-angular/src/core/nested-option.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ export type IOptionPathGetter = () => string;
3535
export const _updateNestedItems = (
3636
items: QueryList<{ propertyName: string; className: string; component: ICollectionNestedOption }>,
3737
setChildrenFn: (propertyName: string, items: QueryList<ICollectionNestedOption>) => void,
38-
{ componentClassName, legacyClassNames }: { componentClassName: string; legacyClassNames: Record<string, string[]> },
38+
{
39+
componentClassName,
40+
legacyClassNames,
41+
currentOptions,
42+
}: { componentClassName: string; legacyClassNames: Record<string, string[]>, currentOptions: Map<string, any> },
3943
) => {
4044
const hasLegacy = {};
4145
const groupedItems = {};
@@ -62,9 +66,16 @@ export const _updateNestedItems = (
6266
const queryList = new QueryList<ICollectionNestedOption>();
6367

6468
queryList.reset(components);
65-
69+
currentOptions.set(propertyName, true);
6670
setChildrenFn(propertyName, queryList);
6771
});
72+
73+
currentOptions.forEach((updated, propertyName) => {
74+
if (!updated) {
75+
setChildrenFn(propertyName, new QueryList<ICollectionNestedOption>());
76+
}
77+
currentOptions.set(propertyName, false);
78+
})
6879
};
6980

7081
@Component({
@@ -82,6 +93,8 @@ export abstract class BaseNestedOption implements INestedOptionContainer, IColle
8293
protected abstract get _optionPath(): string;
8394
protected abstract _fullOptionPath(): string;
8495

96+
private _currentNestedOptions:Map<string, any> = new Map();
97+
8598
constructor() {
8699
this._collectionContainerImpl = new CollectionNestedOptionContainerImpl(this._setOption.bind(this), this._filterItems.bind(this));
87100
}
@@ -94,6 +107,7 @@ export abstract class BaseNestedOption implements INestedOptionContainer, IColle
94107
{
95108
componentClassName: this.constructor.name,
96109
legacyClassNames: null,
110+
currentOptions: this._currentNestedOptions
97111
},
98112
);
99113
}

0 commit comments

Comments
 (0)