Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IgxTreeService } from './tree.service';
import { IgxTreeComponent } from './tree.component';
import { IgxTree, IgxTreeNode, IgxTreeSelectionType } from './common';
import { IgxTreeNodeComponent } from './tree-node/tree-node.component';
import { PlatformUtil } from '../core/utils';

describe('IgxTree - Navigation #treeView', () => {

Expand Down Expand Up @@ -780,7 +781,8 @@ describe('IgxTree - Navigation #treeView', () => {
spyOn(nav, 'update_disabled_cache');
spyOn(nav, 'update_visible_cache');
spyOn(nav, 'register');
const tree = new IgxTreeComponent(nav, mockSelectionService, mockTreeService, mockElementRef);
const mockPlatform = jasmine.createSpyObj('platform', ['isBrowser', 'isServer']);
const tree = new IgxTreeComponent(nav, mockSelectionService, mockTreeService, mockElementRef, mockPlatform);
tree.nodes = mockQuery;
expect(nav.register).toHaveBeenCalledWith(tree);
expect(nav.init_invisible_cache).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ describe('IgxTree - Selection #treeView', () => {
const selectionService = new IgxTreeSelectionService();
const treeService = new IgxTreeService();
const navService = new IgxTreeNavigationService(treeService, selectionService);
const tree = new IgxTreeComponent(navService, selectionService, treeService, null);
const mockPlatform = jasmine.createSpyObj('platform', ['isBrowser', 'isServer']);
mockPlatform.isBrowser = true;
const tree = new IgxTreeComponent(navService, selectionService, treeService, null, mockPlatform);

beforeEach(() => {
mockNodes = TreeTestFunctions.createNodeSpies(0, 5);
Expand Down
12 changes: 8 additions & 4 deletions projects/igniteui-angular/src/lib/tree/tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { IgxTreeNodeComponent } from './tree-node/tree-node.component';
import { IgxTreeSelectionService } from './tree-selection.service';
import { IgxTreeService } from './tree.service';
import { growVerIn, growVerOut } from 'igniteui-angular/animations';
import { resizeObservable } from '../core/utils';
import { PlatformUtil, resizeObservable } from '../core/utils';

/**
* @hidden @internal
Expand Down Expand Up @@ -327,6 +327,7 @@ export class IgxTreeComponent implements IgxTree, OnInit, AfterViewInit, OnDestr
private selectionService: IgxTreeSelectionService,
private treeService: IgxTreeService,
private element: ElementRef<HTMLElement>,
private platform: PlatformUtil
) {
this.selectionService.register(this);
this.treeService.register(this);
Expand Down Expand Up @@ -501,9 +502,12 @@ export class IgxTreeComponent implements IgxTree, OnInit, AfterViewInit, OnDestr
private subToChanges() {
this.unsubChildren$.next();
const toBeSelected = [...this.forceSelect];
requestAnimationFrame(() => {
this.selectionService.selectNodesWithNoEvent(toBeSelected);
});
if(this.platform.isBrowser) {
requestAnimationFrame(() => {
this.selectionService.selectNodesWithNoEvent(toBeSelected);
});
}

this.forceSelect = [];
this.nodes.forEach(node => {
node.expandedChange.pipe(takeUntil(this.unsubChildren$)).subscribe(nodeState => {
Expand Down
5 changes: 4 additions & 1 deletion projects/igniteui-angular/src/lib/tree/tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IgxTreeNodeComponent } from './tree-node/tree-node.component';
import { IgxTreeSelectionService } from './tree-selection.service';
import { IgxTreeComponent } from './tree.component';
import { IgxTreeService } from './tree.service';
import { PlatformUtil } from '../core/utils';

const TREE_ROOT_CLASS = 'igx-tree__root';
const NODE_TAG = 'igx-tree-node';
Expand Down Expand Up @@ -45,8 +46,10 @@ describe('IgxTree #treeView', () => {
mockElementRef = jasmine.createSpyObj('elementRef', [], {
nativeElement: document.createElement('div')
});
const mockPlatform = jasmine.createSpyObj('platform', ['isBrowser', 'isServer']);
mockPlatform.isBrowser = true;
tree?.ngOnDestroy();
tree = new IgxTreeComponent(mockNavService, mockSelectionService, mockTreeService, mockElementRef);
tree = new IgxTreeComponent(mockNavService, mockSelectionService, mockTreeService, mockElementRef, mockPlatform);
mockNodes = jasmine.createSpyObj('mockList', ['toArray'], {
changes: new Subject<void>(),
get first() {
Expand Down
Loading