refactor: make keyboard dismissable on search bars

This commit is contained in:
Rainer Killinger
2022-06-24 08:14:06 +00:00
parent 9d31365d0a
commit 786abdbefa
5 changed files with 27 additions and 2 deletions
@@ -14,6 +14,7 @@
*/
import {Component, Input, OnInit, OnDestroy} from '@angular/core';
import {Router} from '@angular/router';
import {Keyboard} from '@capacitor/keyboard';
import {AlertController} from '@ionic/angular';
import {
SCFacet,
@@ -214,6 +215,13 @@ export class SearchPageComponent implements OnInit, OnDestroy {
}
}
/**
* Hides keyboard in native app environments
*/
hideKeyboard() {
Keyboard.hide();
}
/**
* Set starting values (e.g. forced filter, which can be set in components inheriting this one)
*/
+4 -1
View File
@@ -12,9 +12,12 @@
</ion-buttons>
<ion-searchbar
(ngModelChange)="searchStringChanged($event)"
(keyup.enter)="hideKeyboard()"
[(ngModel)]="queryText"
showClearButton="always"
placeholder="{{ 'search.search_bar.placeholder' | translate }}"
showClearButton="always"
type="search"
enterkeyhint="search"
>
</ion-searchbar>
</ion-toolbar>
@@ -12,9 +12,12 @@
</ion-buttons>
<ion-searchbar
(ngModelChange)="searchStringChanged($event)"
(keyup.enter)="hideKeyboard()"
[(ngModel)]="queryText"
showClearButton="always"
placeholder="{{ 'hebisSearch.search_bar.placeholder' | translate }}"
showClearButton="always"
type="search"
enterkeyhint="search"
>
</ion-searchbar>
</ion-toolbar>
@@ -20,6 +20,7 @@ import {
ViewChild,
} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Keyboard} from '@capacitor/keyboard';
import {
AlertController,
IonRouterOutlet,
@@ -276,6 +277,13 @@ export class MapPageComponent {
}
}
/**
* Hides keyboard in native app environments
*/
hideKeyboard() {
Keyboard.hide();
}
/**
* Subscribe to needed observables and get the location status when user is entering the page
*/
+3
View File
@@ -27,10 +27,13 @@
</ion-buttons>
<ion-searchbar
(keyup)="searchKeyUp($event)"
(keyup.enter)="hideKeyboard()"
[(ngModel)]="queryText"
(ionClear)="searchStringChanged()"
placeholder="{{ 'map.page.search_bar.placeholder' | translate }}"
showClearButton="always"
type="search"
enterkeyhint="search"
>
</ion-searchbar>
<ion-buttons slot="end">