Skip to content

Commit aff057d

Browse files
authored
Merge pull request #13503 from IgniteUI/fix-13502
fix(tree): expand indicator directive #13502
2 parents 82b740a + 95a5df5 commit aff057d

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IgxTreeNodeComponent, IgxTreeNodeLinkDirective } from './tree-node/tree-node.component';
2-
import { IgxTreeComponent } from './tree.component';
2+
import { IgxTreeComponent, IgxTreeExpandIndicatorDirective } from './tree.component';
33

4-
export { IgxTreeComponent } from './tree.component';
4+
export { IgxTreeComponent, IgxTreeExpandIndicatorDirective } from './tree.component';
55
export * from './tree-node/tree-node.component';
66
export { IgxTreeSearchResolver, ITreeNodeSelectionEvent, ITreeNodeEditingEvent,
77
ITreeNodeEditedEvent, ITreeNodeTogglingEventArgs, ITreeNodeToggledEventArgs,
@@ -12,5 +12,6 @@ export { IgxTreeSearchResolver, ITreeNodeSelectionEvent, ITreeNodeEditingEvent,
1212
export const IGX_TREE_DIRECTIVES = [
1313
IgxTreeComponent,
1414
IgxTreeNodeComponent,
15-
IgxTreeNodeLinkDirective
15+
IgxTreeNodeLinkDirective,
16+
IgxTreeExpandIndicatorDirective
1617
] as const;

projects/igniteui-angular/src/lib/tree/tree-navigation.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ describe('IgxTree - Navigation #treeView', () => {
310310
fix.detectChanges();
311311
}));
312312

313+
it('The tree should have custome expand indicator templates', () => {
314+
expect(tree.nodes.first.nativeElement.querySelector('.igx-icon').textContent).toBe('close_fullscreen');
315+
});
316+
313317
it('The tree container should be scrolled so that the focused node is in view', fakeAsync(() => {
314318
// set another node as active element, expect node to be in view
315319
tick();

projects/igniteui-angular/src/lib/tree/tree-node/tree-node.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ export class IgxTreeNodeComponent<T> extends ToggleAnimationPlayer implements Ig
524524

525525
/** @hidden @internal */
526526
public get expandIndicatorTemplate(): TemplateRef<any> {
527-
return this.tree?.expandIndicator ? this.tree.expandIndicator : this._defaultExpandIndicatorTemplate;
527+
return this.tree?.expandIndicator || this._defaultExpandIndicatorTemplate;
528528
}
529529

530530
/**

projects/igniteui-angular/src/lib/tree/tree-samples.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Component, ViewChild, ChangeDetectorRef } from '@angular/core';
2-
import { IgxTreeComponent, IgxTreeNodeComponent, IgxTreeNodeLinkDirective } from './public_api';
2+
import { IgxTreeComponent, IgxTreeExpandIndicatorDirective, IgxTreeNodeComponent, IgxTreeNodeLinkDirective } from './public_api';
33
import { HIERARCHICAL_SAMPLE_DATA } from 'src/app/shared/sample-data';
44
import { NgFor, NgIf, NgTemplateOutlet } from '@angular/common';
5+
import { IgxIconComponent } from '../icon/icon.component';
56

67
@Component({
78
template: `
@@ -118,10 +119,13 @@ export class IgxTreeNavigationComponent {
118119
</igx-tree-node>
119120
</igx-tree-node>
120121
</igx-tree-node>
122+
<ng-template igxTreeExpandIndicator let-expanded>
123+
<igx-icon>{{ expanded ? "close_fullscreen": "open_in_full"}}</igx-icon>
124+
</ng-template>
121125
</igx-tree>
122126
`,
123127
standalone: true,
124-
imports: [IgxTreeComponent, IgxTreeNodeComponent, NgFor]
128+
imports: [IgxTreeComponent, IgxTreeNodeComponent, IgxTreeExpandIndicatorDirective, IgxIconComponent, NgFor]
125129
})
126130
export class IgxTreeScrollComponent {
127131
@ViewChild(IgxTreeComponent, { static: true }) public tree: IgxTreeComponent;

src/app/tree/tree.sample.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
<ng-template #nodeTemplate let-node>
102102
<a [igxTreeNodeLink]="node" href="https://google.com">Link to Google</a>
103103
</ng-template>
104+
<ng-template igxTreeExpandIndicator let-expanded>
105+
<igx-icon>{{ expanded ? "close_fullscreen": "open_in_full"}}</igx-icon>
106+
</ng-template>
104107
</igx-tree>
105108
</div>
106109

src/app/tree/tree.sample.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FormsModule } from '@angular/forms';
55
import {
66
DisplayDensity, growVerIn, growVerOut,
77
IgxTreeNodeComponent, IgxTreeSearchResolver, IgxTreeComponent, ITreeNodeTogglingEventArgs,
8-
ITreeNodeToggledEventArgs, ITreeNodeSelectionEvent, IgxTreeNode, IgxButtonDirective, IgxButtonGroupComponent, IgxIconComponent, IgxInputDirective, IgxInputGroupComponent, IgxLabelDirective, IgxLayoutDirective, IgxSwitchComponent, IgxTreeNodeLinkDirective
8+
ITreeNodeToggledEventArgs, ITreeNodeSelectionEvent, IgxTreeNode, IgxButtonDirective, IgxButtonGroupComponent, IgxIconComponent, IgxInputDirective, IgxInputGroupComponent, IgxLabelDirective, IgxLayoutDirective, IgxSwitchComponent, IgxTreeNodeLinkDirective, IgxTreeExpandIndicatorDirective
99
} from 'igniteui-angular';
1010
import { Subject } from 'rxjs';
1111
import { cloneDeep } from 'lodash-es';
@@ -35,7 +35,15 @@ interface CompanyData {
3535
templateUrl: 'tree.sample.html',
3636
styleUrls: ['tree.sample.scss'],
3737
standalone: true,
38-
imports: [IgxLayoutDirective, IgxInputGroupComponent, IgxInputDirective, IgxButtonDirective, IgxLabelDirective, FormsModule, IgxSwitchComponent, IgxButtonGroupComponent, IgxTreeComponent, IgxTreeNodeComponent, NgFor, IgxTreeNodeLinkDirective, NgTemplateOutlet, IgxIconComponent, NgIf, AsyncPipe]
38+
imports: [
39+
IgxLayoutDirective,
40+
IgxInputGroupComponent,
41+
IgxInputDirective,
42+
IgxButtonDirective,
43+
IgxLabelDirective,
44+
FormsModule,
45+
IgxSwitchComponent,
46+
IgxButtonGroupComponent, IgxTreeComponent, IgxTreeNodeComponent, NgFor, IgxTreeNodeLinkDirective, IgxTreeExpandIndicatorDirective, NgTemplateOutlet, IgxIconComponent, NgIf, AsyncPipe]
3947
})
4048
export class TreeSampleComponent implements AfterViewInit {
4149
@ViewChild('tree1', { static: true })

0 commit comments

Comments
 (0)