Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix(tag-list): Fixes an issue where the taglist did not get updated
Browse files Browse the repository at this point in the history
within a tree table.

When running inside of a tree table, the table row does only get updated
when the differ of the tree table triggers a repaint. As the tag-list
itself marks itself dirty, but change detection never runs for it
because no differ detectable changes happened.

Fixes #603
  • Loading branch information
tomheller committed Feb 18, 2020
1 parent 3719910 commit b796ed5
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/dev/src/tree-table/tree-table-demo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@
<dt-tree-table-header-cell *dtHeaderCellDef>
Running
</dt-tree-table-header-cell>
<dt-cell *dtCellDef="let row">{{ row.running }}ms</dt-cell>
<dt-cell *dtCellDef="let row">
<dt-tag-list>
<dt-tag *ngFor="let tag of row.tags">
{{ tag }}
</dt-tag>
</dt-tag-list>
</dt-cell>
</ng-container>

<ng-container dtColumnDef="waiting">
Expand Down
99 changes: 99 additions & 0 deletions apps/dev/src/tree-table/tree-table-demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 123,
running: 20,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
children: [
{
name:
Expand All @@ -44,6 +56,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 123,
running: 20,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
},
{
name: 'hz.hzInstance_1_cluster.thread-2',
Expand All @@ -53,6 +77,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 130,
running: 0,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
},
],
},
Expand All @@ -64,6 +100,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 123,
running: 20,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
children: [
{
name: 'jetty-422',
Expand All @@ -73,6 +121,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 123,
running: 20,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
},
{
name: 'jetty-423',
Expand All @@ -82,6 +142,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 130,
running: 0,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
},
{
name: 'jetty-424',
Expand All @@ -91,6 +163,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 130,
running: 0,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
},
],
},
Expand All @@ -102,6 +186,18 @@ const TESTDATA: ThreadNode[] = [
waiting: 123,
running: 20,
blocked: 0,
tags: [
'tag one',
'Pineapple',
'Apple',
'Avocado',
'Jackfruit',
'oranage',
'tag two',
'cucumber',
'paprika',
'apple',
],
},
];

Expand All @@ -110,6 +206,7 @@ export class ThreadNode {
threadlevel: string;
totalTimeConsumption: number;
blocked: number;
tags: string[];
running: number;
waiting: number;
icon: DtIconType;
Expand All @@ -121,6 +218,7 @@ export class ThreadFlatNode {
threadlevel: string;
totalTimeConsumption: number;
blocked: number;
tags: string[];
running: number;
waiting: number;
icon: DtIconType;
Expand Down Expand Up @@ -187,6 +285,7 @@ export class TreeTableDemo {
flatNode.blocked = node.blocked;
flatNode.running = node.running;
flatNode.waiting = node.waiting;
flatNode.tags = node.tags;
flatNode.totalTimeConsumption = node.totalTimeConsumption;
flatNode.icon = node.icon;
this.flatNodeMap.set(flatNode, node);
Expand Down
8 changes: 7 additions & 1 deletion components/tag/src/tag-list/tag-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class DtTagList implements AfterContentInit, OnDestroy {

ngAfterContentInit(): void {
if (this._platform.isBrowser) {
// Changes need to be re-evaluated if
this._tagElements.changes
.pipe(
startWith(null),
Expand All @@ -125,7 +126,12 @@ export class DtTagList implements AfterContentInit, OnDestroy {
this._isOneLine = true;
}
}
this._changeDetectorRef.markForCheck();
// When running inside of a tree table, the table row does only get updated
// when the differ of the tree table triggers a repaint. As the tag-list
// itself marks itself dirty, but change detection never runs for it because
// no differ detectable changes happened.
// We need to run detectChanges here to actually update the number indicator
this._changeDetectorRef.detectChanges();
});
this._tagAddElements.changes
.pipe(startWith(null), takeUntil(this._destroy$))
Expand Down

0 comments on commit b796ed5

Please sign in to comment.