Hi all, I’m using Ionic 3 and MKWebView. I want to achieve a search screen that overlay current screen, auto focus on the input, and show the keyboard.
However every time the keyboard shows up, it push the view upward. This is the video of it: youtube
Those are my code:
HTML:
<ion-content padding fullscreen overflow-scroll=”true” [ngClass]="{'blur': showSearchScreen}" #body>
</ion-content>
<div *ngIf="showSearchScreen" class="overlay">
<div class="search-box-wrapper">
<ion-input type="text" [(ngModel)]="searchText" class="search-box" placeholder="Type search term" #searchInput [focus]="searchInput">
</ion-input>
</div>
</div>
.ts:
@ViewChild('searchInput') searchInput ;
And the auto focus directive:
@Directive({
selector: '[focus]' // Attribute selector
})
export class FocusDirective {
@Input() focus: any;
constructor(){
}
ngAfterViewInit(){
this.focus.setFocus();
}
}
config.xml
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
I tried some solutions but none worked for me. Any suggestion is highly appreciated. Thank in advance.