mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-18 11:05:41 +01:00
Close browser popup on Escape key press
This commit is contained in:
parent
8d2e436a05
commit
aee1968436
@ -7,7 +7,7 @@
|
||||
</div>
|
||||
<div class="search">
|
||||
<input type="{{searchTypeSearch ? 'search' : 'text'}}" placeholder="{{'searchVault' | i18n}}" id="search"
|
||||
[(ngModel)]="searchText" (input)="searchVault()" autocomplete="off">
|
||||
[(ngModel)]="searchText" (input)="searchVault()" autocomplete="off" (keydown)="closeOnEsc($event)">
|
||||
<i class="fa fa-search" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="right">
|
||||
|
@ -231,4 +231,11 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
|
||||
this.loginCiphers = this.loginCiphers.sort((a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b));
|
||||
this.loaded = true;
|
||||
}
|
||||
|
||||
closeOnEsc(e: KeyboardEvent) {
|
||||
// If input not empty, use browser default behavior of clearing input instead
|
||||
if (e.key === 'Escape' && (this.searchText == null || this.searchText === '')) {
|
||||
BrowserApi.closePopup(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
</div>
|
||||
<div class="search">
|
||||
<input type="{{searchTypeSearch ? 'search' : 'text'}}" placeholder="{{'searchVault' | i18n}}" id="search"
|
||||
[(ngModel)]="searchText" (input)="search(200)" autocomplete="off" appAutofocus>
|
||||
[(ngModel)]="searchText" (input)="search(200)" autocomplete="off" appAutofocus (keydown)="closeOnEsc($event)">
|
||||
<i class="fa fa-search"></i>
|
||||
</div>
|
||||
<div class="right">
|
||||
|
@ -357,4 +357,11 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
closeOnEsc(e: KeyboardEvent) {
|
||||
// If input not empty, use browser default behavior of clearing input instead
|
||||
if (e.key === 'Escape' && (this.searchText == null || this.searchText === '')) {
|
||||
BrowserApi.closePopup(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user