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

@@ -52,6 +52,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
@ViewChild('schedule', {read: ElementRef}) scheduleRef: ElementRef;
@ViewChild('search', {read: ElementRef}) searchRef: ElementRef;
@ViewChild('ionContent') ionContentRef: IonContent;
collapseAnimation: DashboardCollapse;
@@ -88,6 +90,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
},
};
/**
* Offset from search bar to top
*/
searchToTopOffset = 0;
constructor(
private readonly dataRoutingService: DataRoutingService,
private scheduleProvider: ScheduleProvider,
@@ -121,6 +128,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
);
}
ionViewDidEnter() {
this.searchToTopOffset =
this.searchRef.nativeElement?.getBoundingClientRect().top - 100;
}
async loadNextEvent() {
const dataSeries = await this.scheduleProvider.getDateSeries(
this.uuids,
@@ -142,4 +154,15 @@ export class DashboardComponent implements OnInit, OnDestroy {
this._uuidSubscription.unsubscribe();
this.collapseAnimation.destroy();
}
async onSearchBarFocus(_event: Event) {
this.ionContentRef.getScrollElement().then(element => {
if (
element.scrollHeight - element.clientHeight >=
this.searchToTopOffset
) {
this.ionContentRef.scrollToPoint(0, this.searchToTopOffset, 100);
}
});
}
}