fix: make keyboard dismissable on mobile devices

This commit is contained in:
Rainer Killinger
2022-09-23 13:48:07 +00:00
parent 4a3f79ca20
commit b2cc1fd91f
10 changed files with 86 additions and 7 deletions

View File

@@ -14,6 +14,8 @@
*/
import {Component} from '@angular/core';
import {Router} from '@angular/router';
import {Capacitor} from '@capacitor/core';
import {Keyboard} from '@capacitor/keyboard';
/**
* Shows a search input field
@@ -32,6 +34,17 @@ export class SearchSectionComponent {
* User submits search
*/
onSubmitSearch() {
this.router.navigate(['/search', this.searchTerm]);
this.router
.navigate(['/search', this.searchTerm])
.then(() => this.hideKeyboard());
}
/**
* Hides keyboard in native app environments
*/
hideKeyboard() {
if (Capacitor.isNativePlatform()) {
Keyboard.hide();
}
}
}