From 37b30ad02f8d874d63739b2f7348987df0704c94 Mon Sep 17 00:00:00 2001 From: cvs Date: Tue, 8 Aug 2017 13:58:00 +0200 Subject: [PATCH 1/2] Correct a problem with mouseenter (with best performance) --- src/angular.template.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/angular.template.html b/src/angular.template.html index 2356502..03afcb8 100644 --- a/src/angular.template.html +++ b/src/angular.template.html @@ -48,13 +48,13 @@ role="tree" tabindex="-1" (keydown)="keyDown($event)"> - +
  • {{groupOrOption.label}}
      -
    • Date: Tue, 8 Aug 2017 14:12:07 +0200 Subject: [PATCH 2/2] Fix the list closing when there click on another select2 --- src/angular.component.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/angular.component.ts b/src/angular.component.ts index 95bf56a..f0e8648 100644 --- a/src/angular.component.ts +++ b/src/angular.component.ts @@ -290,13 +290,20 @@ export class Select2 implements ControlValueAccessor { this.toggleOpenAndClose(); } if (!this.ifParentContainsId(e.target as HTMLElement, this._id)) { - this.focused = false; - window.document.body.removeEventListener("click", this._clickDetectionFc); - this._clickDetection = false; + this.clickExit(); } + } else if (this.isOpen && !this.ifParentContainsId(e.target as HTMLElement, this._id)) { + this.toggleOpenAndClose(); + this.clickExit(); } } + clickExit() { + this.focused = false; + window.document.body.removeEventListener("click", this._clickDetectionFc); + this._clickDetection = false; + } + ifParentContainsClass(element: HTMLElement, cssClass: string): boolean { return this.getParentElementByClass(element, cssClass) !== null; } @@ -463,6 +470,10 @@ export class Select2 implements ControlValueAccessor { } } + trackBy(index: number, item: common.Select2Option): any { + return item.value; + } + searchUpdate(e: Event) { this.searchText = (e.target as HTMLInputElement).value; }