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

Commit

Permalink
fix(filter-field): Improving multiselect uid generation; clearing sel…
Browse files Browse the repository at this point in the history
…ected list on delete.
  • Loading branch information
PedroMosquera authored and tomheller committed May 10, 2021
1 parent ce4f5ff commit 94ffa9a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { Route, RouterModule } from '@angular/router';
import { DtOverlayModule } from '@dynatrace/barista-components/overlay';
import { DtSunburstChartModule } from '@dynatrace/barista-components/sunburst-chart';
import { DtE2ESunburstChart } from './sunburst-chart';

const routes: Route[] = [{ path: '', component: DtE2ESunburstChart }];

@NgModule({
declarations: [DtE2ESunburstChart],
imports: [CommonModule, RouterModule.forChild(routes), DtSunburstChartModule],
imports: [
CommonModule,
DtOverlayModule,
RouterModule.forChild(routes),
DtSunburstChartModule,
],
exports: [],
providers: [],
})
Expand Down
12 changes: 10 additions & 2 deletions libs/barista-components/filter-field/src/filter-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,8 @@ export class DtFilterField<T = any>
}
this._resetEditMode();
this._closeFilterPanels();

this._multiSelect._setInitialSelection([]);
this._stateChanges.next();
this._changeDetectorRef.markForCheck();
}
Expand Down Expand Up @@ -1798,11 +1800,17 @@ export class DtFilterField<T = any>
const ids = new Set<string>();
for (const currentFilter of this._filters) {
let currentId = '';
for (const value of currentFilter) {

for (const [index, value] of currentFilter.entries()) {
if (isDtAutocompleteValue(value)) {
const id = peekOptionId(value, currentId);
ids.add(id);
currentId = id;

// In case of multiSelect filter type, the id must not be concatenated.
// So it'll only use the first value which is the parent
if (!isDtMultiSelectValue(currentFilter[0]) || index === 0) {
currentId = id;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions libs/examples/src/sunburst-chart/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ng_module(
tsconfig = "//libs/examples:tsconfig_lib",
deps = [
"//libs/barista-components/button:compile",
"//libs/barista-components/overlay:compile",
"//libs/barista-components/formatters:compile",
"//libs/barista-components/sunburst-chart:compile",
"//libs/barista-components/theming:compile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { NgModule } from '@angular/core';
import { DtButtonModule } from '@dynatrace/barista-components/button';
import { DtOverlayModule } from '@dynatrace/barista-components/overlay';
import { DtSunburstChartModule } from '@dynatrace/barista-components/sunburst-chart';
import { DtThemingModule } from '@dynatrace/barista-components/theming';
import { DtExampleSunburstChartCustomColor } from './sunburst-chart-custom-color-example/sunburst-chart-custom-color-example';
Expand All @@ -29,6 +30,7 @@ import { DtFormattersModule } from '@dynatrace/barista-components/formatters';
DtButtonModule,
DtThemingModule,
DtFormattersModule,
DtOverlayModule,
],
declarations: [
DtExampleSunburstChartDefault,
Expand Down

0 comments on commit 94ffa9a

Please sign in to comment.