Skip to content
Snippets Groups Projects
Commit 33b02fd1 authored by Cindy's avatar Cindy Committed by pybelecalo
Browse files

[US TRTL-678] On search app, put focus on search input

parent bd863eda
No related branches found
No related tags found
10 merge requests!51Merge mis a jour vitam-ui,!25Nouveau mis a jour Vitamui,!24Nouveau mis a jour Vitamui,!23Nouveau mis a jour Vitamui,!22WIP: nouveau mis a jour Vitamui,!21nouveau mis a jour Vitamui,!20nouveau mis à jour Vitamui,!19nouveau mis à jour Vitamui,!18New MAJ Vitamui,!16[VAS] BUG 7332 : Correction sur la position de la barre permettant de...
......@@ -3,7 +3,7 @@
[@opacityAnimation]="state"
>
<div class="row header">
<vitamui-common-search-bar
<vitamui-common-search-bar #searchBar
class="col-5 mr-2"
name="category-search"
(searchChanged)="onSearch($event)"
......
import { animate, keyframes, query, stagger, state, style, transition, trigger } from '@angular/animations';
import { AfterViewInit, ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { MatSelectionList } from '@angular/material/list';
import { MatTabChangeEvent } from '@angular/material/tabs';
import { Router } from '@angular/router';
......@@ -11,6 +11,7 @@ import { Category } from '../../../models';
import { Application } from '../../../models/application/application.interface';
import { TenantSelectionService } from '../../../tenant-selection.service';
import { MenuOption } from '../../navbar';
import { SearchBarComponent } from '../../search-bar';
import { Tenant } from './../../../models/customer/tenant.interface';
import { StartupService } from './../../../startup.service';
import { MenuOverlayRef } from './menu-overlay-ref';
......@@ -39,6 +40,7 @@ export class MenuComponent implements OnInit, AfterViewInit {
private firstResultFocused = false;
private destroyer$ = new Subject();
@ViewChild('searchBar', { static: true }) searchBar: SearchBarComponent;
@ViewChildren(MatSelectionList) selectedList: QueryList<MatSelectionList>;
@HostListener('document:keydown', ['$event'])
handleKeyboardEvent(event: KeyboardEvent) {
......@@ -85,7 +87,7 @@ export class MenuComponent implements OnInit, AfterViewInit {
}
ngAfterViewInit(): void {
this.changeTabFocus();
this.searchBar.onFocus();
}
public onSearch(value: string): void {
......@@ -111,7 +113,7 @@ export class MenuComponent implements OnInit, AfterViewInit {
public resetSearch(): void {
this.filteredApplications = null;
this.criteria = '';
this.changeTabFocus();
this.searchBar.onFocus();
}
public onClose(): void {
......
<div class="search">
<input [(ngModel)]="searchValue" (ngModelChange)="searchChanged.emit(searchValue)" [name]="name" type="text" [placeholder]="placeholder" [disabled]="disabled">
<button *ngIf="searchValue" type="button" class="btn-reset" (click)="reset()" [disabled]="disabled"><i class="material-icons">clear</i></button>
<button type="button" class="btn btn-circle btn-search secondary small" (click)="onSearch()" [disabled]="disabled"><i class="material-icons">search</i></button>
<input
#searchInput
[(ngModel)]="searchValue"
(ngModelChange)="searchChanged.emit(searchValue)"
[name]="name"
type="text"
[placeholder]="placeholder"
[disabled]="disabled"
/>
<button
*ngIf="searchValue"
type="button"
class="btn-reset"
(click)="reset()"
[disabled]="disabled"
>
<i class="material-icons">clear</i>
</button>
<button
type="button"
class="btn btn-circle btn-search secondary small"
(click)="onSearch()"
[disabled]="disabled"
>
<i class="material-icons">search</i>
</button>
</div>
......@@ -34,7 +34,7 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*/
import { Component, EventEmitter, HostListener, Input, OnInit, Output } from '@angular/core';
import { Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output, ViewChild } from '@angular/core';
@Component({
selector: 'vitamui-common-search-bar',
......@@ -55,6 +55,8 @@ export class SearchBarComponent implements OnInit {
@Output() clear = new EventEmitter<string>();
@ViewChild('searchInput', { static: true }) searchInput: ElementRef;
searchValue: string;
constructor() { }
......@@ -73,4 +75,10 @@ export class SearchBarComponent implements OnInit {
this.search.emit(this.searchValue);
}
public onFocus() {
if (this.searchInput) {
setTimeout(() => this.searchInput.nativeElement.focus(), 0);
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment