From 62283d1b328f879075c35b18e31862ff513b13c3 Mon Sep 17 00:00:00 2001 From: Arcadio Quintero Date: Thu, 18 Jul 2024 01:32:48 -0400 Subject: [PATCH] feat(edit-content) ajust logic in clear searh input #28493 --- .../dot-category-field-search.component.ts | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-category-field/components/dot-category-field-search/dot-category-field-search.component.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-category-field/components/dot-category-field-search/dot-category-field-search.component.ts index 7751998753e1..291b06de34fc 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-category-field/components/dot-category-field-search/dot-category-field-search.component.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-category-field/components/dot-category-field-search/dot-category-field-search.component.ts @@ -1,5 +1,3 @@ -import { EMPTY, of } from 'rxjs'; - import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, EventEmitter, input, Output } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @@ -7,7 +5,7 @@ import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { InputTextModule } from 'primeng/inputtext'; -import { debounceTime, switchMap } from 'rxjs/operators'; +import { debounceTime, filter, tap } from 'rxjs/operators'; import { DotMessagePipe } from '@dotcms/ui'; @@ -48,22 +46,15 @@ export class DotCategoryFieldSearchComponent { .pipe( takeUntilDestroyed(), debounceTime(DEBOUNCE_TIME), - switchMap((value: string) => { - if (value.length >= MINIMUM_CHARACTERS) { - return of(value); - } else if (value.length === 0) { + tap((value: string) => { + if (value.length === 0) { this.clearInput(); - - return of(''); } - - return EMPTY; - }) + }), + filter((value: string) => value.length >= MINIMUM_CHARACTERS) ) .subscribe((value: string) => { - if (value.length >= MINIMUM_CHARACTERS) { - this.term.emit(value); - } + this.term.emit(value); }); }