Browse Source

feat(lib): view child signal for tagInput

pull/6497/head
KenTandrian 3 weeks ago
parent
commit
a94c6f68ec
  1. 9
      libs/ui/src/lib/tags-selector/tags-selector.component.ts

9
libs/ui/src/lib/tags-selector/tags-selector.component.ts

@ -9,7 +9,7 @@ import {
OnChanges, OnChanges,
OnInit, OnInit,
signal, signal,
ViewChild viewChild
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { import {
@ -64,13 +64,14 @@ export class GfTagsSelectorComponent
@Input() tags: Tag[]; @Input() tags: Tag[];
@Input() tagsAvailable: Tag[]; @Input() tagsAvailable: Tag[];
@ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>;
public filteredOptions: Subject<Tag[]> = new BehaviorSubject([]); public filteredOptions: Subject<Tag[]> = new BehaviorSubject([]);
public readonly separatorKeysCodes: number[] = [COMMA, ENTER]; public readonly separatorKeysCodes: number[] = [COMMA, ENTER];
public readonly tagInputControl = new FormControl(''); public readonly tagInputControl = new FormControl('');
public readonly tagsSelected = signal<Tag[]>([]); public readonly tagsSelected = signal<Tag[]>([]);
private readonly tagInput =
viewChild.required<ElementRef<HTMLInputElement>>('tagInput');
public constructor() { public constructor() {
this.tagInputControl.valueChanges this.tagInputControl.valueChanges
.pipe(takeUntilDestroyed()) .pipe(takeUntilDestroyed())
@ -114,7 +115,7 @@ export class GfTagsSelectorComponent
this.onTouched(); this.onTouched();
} }
this.tagInput.nativeElement.value = ''; this.tagInput().nativeElement.value = '';
this.tagInputControl.setValue(null); this.tagInputControl.setValue(null);
} }

Loading…
Cancel
Save