Skip to content

Commit e54b1ce

Browse files
Adding focus to the input after the reset button is clicked
1 parent 9565f9b commit e54b1ce

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import {
88
} from '@angular/common';
99
import {
1010
Component,
11+
ElementRef,
1112
EventEmitter,
1213
Input,
1314
OnChanges,
1415
OnDestroy,
1516
OnInit,
1617
Output,
1718
SimpleChanges,
19+
ViewChild,
1820
} from '@angular/core';
1921
import { FormsModule } from '@angular/forms';
2022
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
@@ -70,6 +72,11 @@ export type VocabularyTreeItemType = FormFieldMetadataValueObject | VocabularyEn
7072
})
7173
export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges {
7274

75+
/**
76+
* Implemented to manage focus on input
77+
*/
78+
@ViewChild('searchInput') searchInput: ElementRef;
79+
7380
/**
7481
* The {@link VocabularyOptions} object
7582
*/
@@ -332,6 +339,7 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
332339
this.storedNodeMap = new Map<string, TreeviewFlatNode>();
333340
this.vocabularyTreeviewService.restoreNodes();
334341
}
342+
this.searchInput.nativeElement.focus();
335343
}
336344

337345
add() {

0 commit comments

Comments
 (0)