From 56d42bcd714020f2fec8dd30d2c538734b6ff394 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 9 Jun 2022 15:25:24 +0300 Subject: [PATCH] Search input: on reset focus input and on enter select option then search. Input: If autocomplete_soft is selected then do notselect item from the list by default and close dropdown on enter. --- sharedComponents/input/input.component.ts | 7 +++++-- .../search-input/search-input.component.ts | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sharedComponents/input/input.component.ts b/sharedComponents/input/input.component.ts index fe470718..66475dbb 100644 --- a/sharedComponents/input/input.component.ts +++ b/sharedComponents/input/input.component.ts @@ -310,8 +310,11 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang event.preventDefault(); if (this.filteredOptions[this.selectedIndex]) { this.selectOption(this.filteredOptions[this.selectedIndex], event); - this.open(false); } + this.open(false); + event.stopPropagation(); + } else { + this.focus(false, event); } } @@ -531,7 +534,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang this.cdr.detectChanges(); if (this.optionBox && this.opened) { this.selectedIndex = this.filteredOptions.findIndex(option => option.value === this.formControl.value); - if (this.selectedIndex === -1) { + if (this.selectedIndex === -1 && this.type !== 'autocomplete_soft') { this.selectedIndex = 0; } UIkit.dropdown(this.optionBox.nativeElement).show(); diff --git a/sharedComponents/search-input/search-input.component.ts b/sharedComponents/search-input/search-input.component.ts index 627d5604..705f91a6 100644 --- a/sharedComponents/search-input/search-input.component.ts +++ b/sharedComponents/search-input/search-input.component.ts @@ -23,7 +23,7 @@ import {ClickEvent} from "../../utils/click/click-outside-or-esc.directive";
+ [disabled]="disabled" [showOptionsOnEmpty]="false" [type]="(options.length > 0?'autocomplete_soft':'text')" [options]="options">