From 87f68609c7ad3e9e1c2b695711882716b086e898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Z=C3=A9fling?= Date: Tue, 29 Aug 2023 23:33:31 +0200 Subject: [PATCH] Fix focus on blur --- .../src/lib/select2.component.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/ng-select2-component/src/lib/select2.component.ts b/projects/ng-select2-component/src/lib/select2.component.ts index 245bd0b..4bf0407 100644 --- a/projects/ng-select2-component/src/lib/select2.component.ts +++ b/projects/ng-select2-component/src/lib/select2.component.ts @@ -688,10 +688,14 @@ export class Select2 implements ControlValueAccessor, OnInit, DoCheck, AfterView } else if (this._testKey(event, ['ArrowDown', 'ArrowUp', 'Enter', 40, 38, 13])) { this.toggleOpenAndClose(true, true, event); event.preventDefault(); - } else if (this._testKey(event, ['Escape', 'Tab', 9, 27]) && this.isOpen) { - this.toggleOpenAndClose(false); - event.preventDefault(); - this._onTouched(); + } else if (this._testKey(event, ['Escape', 'Tab', 9, 27])) { + if (this.isOpen) { + this.toggleOpenAndClose(false); + this._onTouched(); + event.preventDefault(); + } else { + this._focus(false); + } } }