Skip to content

Commit 30aa3ee

Browse files
committed
fix(matrix): resolve MDC chip selection and styling issues
1 parent 8582349 commit 30aa3ee

3 files changed

Lines changed: 50 additions & 22 deletions

File tree

src/app/pages/matrix/matrix.component.css

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22
width: 100%;
33
}
44

5-
.mat-mdc-form-field {
5+
.chip-filter-section {
66
margin: 20px;
7-
margin-bottom: 0;
7+
margin-bottom: 10px;
88
width: 90%;
99
}
1010

11+
.chip-filter-label {
12+
display: block;
13+
font-size: 12px;
14+
font-weight: 400;
15+
margin-bottom: 6px;
16+
opacity: 0.7;
17+
}
18+
19+
mat-divider {
20+
opacity: 100%;
21+
}
22+
1123
.matrix-table {
1224
margin: 20px;
1325
}
@@ -90,7 +102,7 @@
90102
.reset-button {
91103
background-color: #66bb6a;
92104
display: block;
93-
margin: 0 20px;
105+
margin: 10px 0 0 20px;
94106
padding: 7px 12px;
95107
border-radius: 16px;
96108
font: 500 14px / 20px Roboto, 'Helvetica Neue', sans-serif;

src/app/pages/matrix/matrix.component.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div class="content">
22
<app-top-header section="Matrix"></app-top-header>
3-
<mat-form-field class="activity-chip-list">
4-
<mat-label>Dimension Filter</mat-label>
3+
4+
<div class="chip-filter-section">
5+
<label class="chip-filter-label">Dimension Filter</label>
56
<mat-chip-listbox #chipList selectable multiple>
67
<mat-chip-option
78
*ngFor="let dim of filtersDim | keyvalue"
@@ -11,9 +12,12 @@
1112
{{ dim.key }}
1213
</mat-chip-option>
1314
</mat-chip-listbox>
14-
</mat-form-field>
15-
<mat-form-field class="activity-chip-list">
16-
<mat-label>Activity Tag Filter</mat-label>
15+
</div>
16+
17+
<mat-divider></mat-divider>
18+
19+
<div class="chip-filter-section">
20+
<label class="chip-filter-label">Activity Tag Filter</label>
1721
<mat-chip-listbox selectable multiple>
1822
<mat-chip-option
1923
*ngFor="let tag of filtersTag | keyvalue"
@@ -23,7 +27,9 @@
2327
{{ tag.key }}
2428
</mat-chip-option>
2529
</mat-chip-listbox>
26-
</mat-form-field>
30+
</div>
31+
32+
<mat-divider></mat-divider>
2733

2834
<button class="reset-button" (click)="reset()">RESET</button>
2935

@@ -52,7 +58,7 @@
5258
</td>
5359
</ng-container>
5460

55-
<div *ngFor="let level of levels | keyvalue">
61+
<ng-container *ngFor="let level of levels | keyvalue">
5662
<ng-container matColumnDef="{{ level.key }}">
5763
<th mat-header-cell *matHeaderCellDef>{{ level.value }}</th>
5864
<td mat-cell *matCellDef="let element">
@@ -76,7 +82,7 @@
7682
</ul>
7783
</td>
7884
</ng-container>
79-
</div>
85+
</ng-container>
8086
<!-- eslint-enable -->
8187

8288
<!-- No data message -->

src/app/pages/matrix/matrix.component.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Router, NavigationExtras } from '@angular/router';
55
import { LoaderService } from 'src/app/service/loader/data-loader.service';
66
import { Activity, ActivityStore, Data } from 'src/app/model/activity-store';
77
import { UntilDestroy } from '@ngneat/until-destroy';
8-
import { MatChipOption, MatChipListbox, MatChipSelectionChange } from '@angular/material/chips';
8+
import { MatChipListbox, MatChipSelectionChange } from '@angular/material/chips';
99
import { deepCopy } from 'src/app/util/util';
1010
import { DataStore } from 'src/app/model/data-store';
1111
import { perfNow } from 'src/app/util/util';
@@ -153,19 +153,29 @@ export class MatrixComponent implements OnInit {
153153
chipList!: MatChipListbox;
154154

155155
toggleTagFilters(event: MatChipSelectionChange) {
156-
let chip = event.source;
157-
chip.toggleSelected();
158-
this.filtersTag[chip.value] = chip.selected;
159-
console.log(`${perfNow()}: Matrix: Chip flip Tag '${chip.value}: ${chip.selected}`);
160-
this.updateActivitiesBeingDisplayed();
156+
if (!event?.source || event.source.value == null) return;
157+
158+
const value = event.source.value;
159+
const selected = event.selected;
160+
161+
setTimeout(() => {
162+
this.filtersTag[value] = selected;
163+
console.log(`${perfNow()}: Matrix: Chip flip Tag '${value}: ${selected}`);
164+
this.updateActivitiesBeingDisplayed();
165+
});
161166
}
162167

163168
toggleDimensionFilters(event: MatChipSelectionChange) {
164-
let chip = event.source;
165-
chip.toggleSelected();
166-
this.filtersDim[chip.value] = chip.selected;
167-
console.log(`${perfNow()}: Matrix: Chip flip Dim '${chip.value}: ${chip.selected}`);
168-
this.updateActivitiesBeingDisplayed();
169+
if (!event?.source || event.source.value == null) return;
170+
171+
const value = event.source.value;
172+
const selected = event.selected;
173+
174+
setTimeout(() => {
175+
this.filtersDim[value] = selected;
176+
console.log(`${perfNow()}: Matrix: Chip flip Dim '${value}: ${selected}`);
177+
this.updateActivitiesBeingDisplayed();
178+
});
169179
}
170180

171181
@ViewChild('rowInput') rowInput!: ElementRef<HTMLInputElement>;

0 commit comments

Comments
 (0)