#3794 Submit mit Enter und Lupen-Symbol führt zu unterschiedliche Ergebnisse

This commit is contained in:
Lorenz Hilpert
2023-02-16 11:31:24 +01:00
parent 138974bca7
commit 76596939c5
3 changed files with 25 additions and 4 deletions

View File

@@ -18,7 +18,7 @@
</button>
<ng-container *ngIf="!loading">
<button tabindex="0" class="search-button search" *ngIf="!canScan" (click)="search.emit(query)">
<button tabindex="0" class="search-button search" *ngIf="!canScan" (click)="emitSearch()" [disabled]="completeValue !== query">
<ui-icon icon="search" size="28px"></ui-icon>
</button>
<button tabindex="0" class="search-button scan" *ngIf="canScan" (click)="startScan()">

View File

@@ -46,6 +46,12 @@
}
}
}
&:disabled {
ui-icon {
@apply text-gray-300;
}
}
}
.clear-button {

View File

@@ -49,8 +49,16 @@ export class UiSearchboxNextComponent extends UiFormControlDirective<any>
@Input()
placeholder: string = '';
private _query = '';
@Input()
query: string = '';
get query() {
return this._query;
}
set query(value: string) {
this._query = value;
this.completeValue = value;
}
@Output()
queryChange = new EventEmitter<string>();
@@ -58,6 +66,7 @@ export class UiSearchboxNextComponent extends UiFormControlDirective<any>
@Output()
search = new EventEmitter<string>();
completeValue = this.query;
@Output()
complete = new EventEmitter<string>();
@@ -117,6 +126,7 @@ export class UiSearchboxNextComponent extends UiFormControlDirective<any>
writeValue(obj: any): void {
this.setQuery(obj, false);
this.completeValue = obj;
}
registerOnChange(fn: any): void {
@@ -166,13 +176,14 @@ export class UiSearchboxNextComponent extends UiFormControlDirective<any>
}
setQuery(query: string, emitEvent: boolean = true, complete?: boolean) {
this.query = query;
this._query = query;
if (emitEvent) {
this.queryChange.emit(query);
this.onChange(query);
this.onTouched();
}
if (complete) {
this.completeValue = query;
this.complete.emit(query);
}
this.cdr.markForCheck();
@@ -206,7 +217,7 @@ export class UiSearchboxNextComponent extends UiFormControlDirective<any>
this.autocomplete?.handleKeyboardEvent(event);
if (this.autocomplete?.activeItem) {
const query = this.autocompleteValueSelector(this.autocomplete.activeItem.item);
this.setQuery(query, false);
this.setQuery(query, false, false);
}
}
@@ -217,6 +228,10 @@ export class UiSearchboxNextComponent extends UiFormControlDirective<any>
}
}
emitSearch() {
this.search.emit(this.query);
}
@HostListener('focusout', ['$event'])
onBlur() {
this.onTouched();