Skip to content

Commit 14680b0

Browse files
Andrea-Guevaratdonohue
authored andcommitted
Adding focus to the input after the reset button is clicked
1 parent b601405 commit 14680b0

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="treeview-header row mb-1">
33
<div class="col-12">
44
<div class="input-group">
5-
<input type="text" class="form-control" [(ngModel)]="searchText" (keyup.enter)="search()"
5+
<input #searchInput type="text" class="form-control" [(ngModel)]="searchText" (keyup.enter)="search()"
66
[attr.aria-label]="'vocabulary-treeview.search.form.search-placeholder' | translate"
77
[placeholder]="'vocabulary-treeview.search.form.search-placeholder' | translate">
88
<div class="input-group-append" id="button-addon4">

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FlatTreeControl } from '@angular/cdk/tree';
2-
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, OnChanges, SimpleChanges } from '@angular/core';
2+
import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, OnChanges, SimpleChanges, ViewChild } from '@angular/core';
33

44
import { Observable, Subscription } from 'rxjs';
55
import { Store } from '@ngrx/store';
@@ -29,6 +29,11 @@ import { AlertType } from '../../alert/alert-type';
2929
})
3030
export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges {
3131

32+
/**
33+
* Implemented to manage focus on input
34+
*/
35+
@ViewChild('searchInput') searchInput: ElementRef;
36+
3237
/**
3338
* The {@link VocabularyOptions} object
3439
*/
@@ -294,6 +299,7 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
294299
this.storedNodeMap = new Map<string, TreeviewFlatNode>();
295300
this.vocabularyTreeviewService.restoreNodes();
296301
}
302+
this.searchInput.nativeElement.focus();
297303
}
298304

299305
add() {

0 commit comments

Comments
 (0)