Skip to content

Commit

Permalink
test(searchbar): searchbar + modal
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Sep 26, 2016
1 parent 8c84cc9 commit 514fed8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/searchbar/searchbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class Searchbar extends Ion {
this.onTouched = fn;
}

focus() {
this.getNativeElement().focus();
setFocus() {
this._renderer.invokeElementMethod(this._searchbarInput.nativeElement, 'focus');
}
}
21 changes: 19 additions & 2 deletions src/components/searchbar/test/nav/app-module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, NgModule } from '@angular/core';
import { IonicApp, IonicModule, NavController, NavParams } from '../../../..';
import { IonicApp, IonicModule, ModalController, NavController, NavParams, ViewController } from '../../../..';


@Component({
Expand All @@ -13,13 +13,23 @@ export class MainPage {
}
}

@Component({
templateUrl: 'modal.html'
})
export class ModalPage {
constructor(public viewCtrl: ViewController) {}
close() {
this.viewCtrl.dismiss();
}
}

@Component({
templateUrl: 'search.html'
})
export class SearchPage {
items: string[];

constructor(public navCtrl: NavController) {
constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
this.initializeItems();
}

Expand Down Expand Up @@ -88,6 +98,11 @@ export class SearchPage {
return false;
});
}

openModal() {
let modal = this.modalCtrl.create(ModalPage);
modal.present();
}
}

@Component({
Expand Down Expand Up @@ -121,6 +136,7 @@ export class E2EApp {
E2EApp,
MainPage,
SearchPage,
ModalPage,
DetailPage,
TabsPage
],
Expand All @@ -132,6 +148,7 @@ export class E2EApp {
E2EApp,
MainPage,
SearchPage,
ModalPage,
DetailPage,
TabsPage
]
Expand Down
21 changes: 21 additions & 0 deletions src/components/searchbar/test/nav/modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<ion-header>
<ion-toolbar>
<ion-buttons start>
<button ion-button >
Does nothing
</button>
</ion-buttons>
<ion-buttons end>
<button ion-button (click)="close()">
Close
</button>
</ion-buttons>
</ion-toolbar>
</ion-header>

<ion-content padding>
Close the modal with the button and the searchbar SHOULD NOT become focused.
<button ion-button (click)="close()">
Close
</button>
</ion-content>
10 changes: 6 additions & 4 deletions src/components/searchbar/test/nav/search.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<ion-header>

<ion-navbar no-border-bottom>
<ion-title>Searchbar</ion-title>
<ion-searchbar color="primary" autofocus (ionInput)="getItems($event)" placeholder="Filter Schedules">
</ion-searchbar>
</ion-navbar>

<ion-toolbar no-border-top>
<ion-searchbar color="primary" (ionInput)="getItems($event)" placeholder="Filter Schedules">
</ion-searchbar>
<ion-title>Searchbar</ion-title>
<ion-buttons end>
<button ion-button (click)="openModal()">Open modal</button>
</ion-buttons>
</ion-toolbar>

</ion-header>


<ion-content>

<form>
Expand Down

0 comments on commit 514fed8

Please sign in to comment.