From d5fbe714211fd76487dfffe219c424910cd45e07 Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Mon, 20 Jul 2020 07:36:45 +0000 Subject: [PATCH] fix(filter-field): Fixes an issue where the range stayed open when datasource updated. When the data is newly set, the currentDef of the filter field is reset. But because the range overlay was open, it held the focus which meant that the stateChanges iteration was not executed, as this only executes its logic when the filterfield has focus. Relates to #1256 --- .../filter-field/src/filter-field.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/barista-components/filter-field/src/filter-field.ts b/libs/barista-components/filter-field/src/filter-field.ts index 098f7d1363..23ec71475a 100644 --- a/libs/barista-components/filter-field/src/filter-field.ts +++ b/libs/barista-components/filter-field/src/filter-field.ts @@ -1107,6 +1107,16 @@ export class DtFilterField this._removeFilter(this._currentFilterValues); this._currentFilterValues = []; this._filterByLabel = ''; + + // If the current def is a range during the reset, + // we need to handle a couple of extra things about the range, i.e. + // closing it and restoring the focus. + if (isDtRangeDef(this._currentDef)) { + if (this._filterfieldRange.isOpen) { + this._filterfieldRangeTrigger.closePanel(); + this.focus(); + } + } } this._currentDef = def; this._updateControl();