Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1773629
fix(cdk/tree): add test that demonstrates issue
BobobUnicorn Sep 16, 2024
37f75e9
fix(cdk/tree): signalize render pipeline
BobobUnicorn Sep 16, 2024
c0406a8
fix(cdk/tree): fix lint errors
BobobUnicorn Sep 17, 2024
9dcfa35
fix(cdk/tree): update API goldens
BobobUnicorn Sep 17, 2024
7b14b85
fix(cdk/tree): formatting
BobobUnicorn Sep 17, 2024
a31f246
fix(cdk/tree): update goldens
BobobUnicorn Sep 17, 2024
dda9c79
refactor(cdk/tree): make tests compiled, gets rid of one `detectChanges`
BobobUnicorn Sep 19, 2024
78cc5c0
refactor(cdk/tree): fold more data computation into signals
BobobUnicorn Sep 20, 2024
a9c989e
fix(cdk/tree): remove unnecessary `async`
BobobUnicorn Sep 20, 2024
856fdd1
fix(cdk/tree): revert to ng_test_library; ng_module tests don't work …
BobobUnicorn Oct 3, 2024
b9dab16
fix(cdk/tree): revert signal changes for tests
BobobUnicorn Oct 3, 2024
8ca9455
refactor(cdk/tree): signalify `_flattenedNodes`
BobobUnicorn Oct 3, 2024
d58e9d9
refactor(cdk/tree): signalify the data rendering
BobobUnicorn Oct 3, 2024
312b578
refactor(cdk/tree): signalify the trackBy/expansionKey functions
BobobUnicorn Oct 3, 2024
327d6ad
fix(cdk/tree): remove duplicate `detectChanges`
BobobUnicorn Oct 3, 2024
7358786
fix(cdk/tree): fix lints
BobobUnicorn Oct 3, 2024
68b29d9
fix(cdk/tree): tests
BobobUnicorn Nov 6, 2024
ae9c2f5
fix(cdk/tree): change inputs back to regular @Input
BobobUnicorn Nov 6, 2024
93a959b
fix(cdk/tree): update goldens, fix lints
BobobUnicorn Nov 7, 2024
49330bb
fix(cdk/tree): formatting
BobobUnicorn Nov 7, 2024
cb4edf0
fix(cdk/tree): api goldens, again
BobobUnicorn Nov 7, 2024
be104c2
fix(cdk/tree): lint
BobobUnicorn Nov 18, 2024
ecc4070
fix(cdk/tree): format
BobobUnicorn Nov 18, 2024
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
Prev Previous commit
Next Next commit
fix(cdk/tree): tests
  • Loading branch information
BobobUnicorn committed Nov 18, 2024
commit 68b29d9f91c4c0daa46b7ebe5c29c8164d309337
6 changes: 6 additions & 0 deletions src/cdk/a11y/key-manager/tree-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyMana
if (newIndex > -1 && newIndex !== this._activeItemIndex) {
this._activeItemIndex = newIndex;
this._typeahead?.setCurrentSelectedItemIndex(newIndex);
} else if (newIndex === -1) {
// if there's no new matching element, then we reset the state of this
// key manager
this._activeItem = null;
this._activeItemIndex = -1;
this._hasInitialFocused = false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/tree/tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,7 @@ describe('CdkTree', () => {
fixture.destroy();

fixture = TestBed.createComponent(StaticNestedCdkTreeApp);
fixture.detectChanges();

component = fixture.componentInstance;
dataSource = component.dataSource as FakeDataSource;
Expand All @@ -1273,7 +1274,6 @@ describe('CdkTree', () => {
it('the tree does not have a tabindex when an element is active', () => {
// activate the second child by clicking on it
nodes[1].click();
fixture.detectChanges();

expect(treeElement.hasAttribute('tabindex')).toBeFalse();
});
Expand Down
13 changes: 1 addition & 12 deletions src/cdk/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,15 +633,7 @@ export class CdkTree<T, K = T>
}
});

// Note: we only `detectChanges` from a top-level call, otherwise we risk overflowing
// the call stack since this method is called recursively (see #29733.)
// TODO: change to `this._changeDetectorRef.markForCheck()`,
// or just switch this component to use signals.
if (parentData) {
this._changeDetectorRef.markForCheck();
} else {
this._changeDetectorRef.detectChanges();
}
this._changeDetectorRef.markForCheck();
}

/**
Expand Down Expand Up @@ -1480,7 +1472,6 @@ export class CdkTreeNode<T, K = T> implements OnDestroy, OnInit, TreeKeyManagerI
/** Focuses this data node. Implemented for TreeKeyManagerItem. */
focus(): void {
this._tabindex.set(0);
this._changeDetectorRef.detectChanges();
if (this._shouldFocus) {
this._elementRef.nativeElement.focus();
}
Expand All @@ -1489,7 +1480,6 @@ export class CdkTreeNode<T, K = T> implements OnDestroy, OnInit, TreeKeyManagerI
/** Defocus this data node. */
unfocus(): void {
this._tabindex.set(-1);
this._changeDetectorRef.detectChanges();
}

/** Emits an activation event. Implemented for TreeKeyManagerItem. */
Expand Down Expand Up @@ -1517,7 +1507,6 @@ export class CdkTreeNode<T, K = T> implements OnDestroy, OnInit, TreeKeyManagerI
/** Makes the node focusable. Implemented for TreeKeyManagerItem. */
makeFocusable(): void {
this._tabindex.set(0);
this._changeDetectorRef.detectChanges();
}

_focusItem() {
Expand Down