From b26df47f487b4f3476a7bea9fad94b262e49d067 Mon Sep 17 00:00:00 2001 From: Michael Fichtinger Date: Mon, 18 Dec 2017 06:25:51 +0100 Subject: [PATCH] fix unexpected closing of multiselect dropdown --- src/materialize-directive.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/materialize-directive.ts b/src/materialize-directive.ts index 68365e6..3c256b7 100644 --- a/src/materialize-directive.ts +++ b/src/materialize-directive.ts @@ -89,7 +89,14 @@ export class MaterializeDirective implements AfterViewInit,DoCheck,OnChanges,OnD public ngOnChanges(_unused?) { if (this.isSelect()) { - setTimeout(() => this.performLocalElementUpdates(), 10); + const nativeElement = this._el.nativeElement; + const jQueryElement = $(nativeElement); + + // run performLocalElementUpdates() only if dropdown closed + // otherwise the dropdown closes unexpected + if (!jQueryElement.attr("multiple") || jQueryElement.parent().find("input.active").length === 0) { + setTimeout(() => this.performLocalElementUpdates(), 10); + } } }