Skip to content

Commit 63b60eb

Browse files
authored
Fix #339 (#340)
1 parent d2262e7 commit 63b60eb

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

src/core/nested-option.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ export class CollectionNestedOptionContainerImpl implements ICollectionNestedOpt
6767
constructor(private _setOption: Function, private _filterItems?: Function) {}
6868

6969
setChildren<T extends ICollectionNestedOption>(propertyName: string, items: QueryList<T>) {
70+
if (this._filterItems) {
71+
items = this._filterItems(items);
72+
}
7073
if (items.length) {
7174
this._activatedQueries[propertyName] = true;
7275
}
7376
if (this._activatedQueries[propertyName]) {
74-
if (this._filterItems) {
75-
items = this._filterItems(items);
76-
}
7777
let widgetItems = items.map((item, index) => {
7878
item._index = index;
7979
return item._value;

tests/src/ui/toolbar.spec.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* tslint:disable:component-selector */
2+
3+
import {
4+
Component,
5+
ViewChildren,
6+
QueryList
7+
} from '@angular/core';
8+
9+
import {
10+
TestBed,
11+
async
12+
} from '@angular/core/testing';
13+
14+
import DxToolbar from 'devextreme/ui/toolbar';
15+
16+
import {
17+
DxToolbarModule,
18+
DxToolbarComponent
19+
} from '../../../dist';
20+
21+
@Component({
22+
selector: 'test-container-component',
23+
template: ''
24+
})
25+
class TestContainerComponent {
26+
@ViewChildren(DxToolbarComponent) innerWidgets: QueryList<DxToolbarComponent>;
27+
}
28+
29+
describe('DxToolbar', () => {
30+
31+
beforeEach(() => {
32+
TestBed.configureTestingModule(
33+
{
34+
declarations: [TestContainerComponent],
35+
imports: [DxToolbarModule]
36+
});
37+
});
38+
39+
function getWidget(fixture) {
40+
let widgetElement = fixture.nativeElement.querySelector('.dx-toolbar') || fixture.nativeElement;
41+
return DxToolbar['getInstance'](widgetElement);
42+
}
43+
44+
// spec
45+
it('should not initialize the "items" property of an item if no children are declared inside the item (T472434)', async(() => {
46+
TestBed.overrideComponent(TestContainerComponent, {
47+
set: {
48+
template: `
49+
<dx-toolbar>
50+
<dxi-item>Item1</dxi-item>
51+
</dx-toolbar>
52+
`
53+
}
54+
});
55+
let fixture = TestBed.createComponent(TestContainerComponent);
56+
fixture.detectChanges();
57+
58+
let instance = getWidget(fixture);
59+
expect(instance.option('items')[0].items).toBe(undefined);
60+
expect(instance.element().find('.dx-toolbar-item').text()).toBe('Item1');
61+
}));
62+
63+
});

0 commit comments

Comments
 (0)