Skip to content

Commit

Permalink
feat(edit-content) ajust logic in clear searh input #28493
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra committed Jul 18, 2024
1 parent 53d8fa5 commit 62283d1
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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';
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';

Expand Down Expand Up @@ -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);
});
}

Expand Down

0 comments on commit 62283d1

Please sign in to comment.