diff --git a/ionic/components/select/select.ts b/ionic/components/select/select.ts index 41942a137cf..476dfaa5c93 100644 --- a/ionic/components/select/select.ts +++ b/ionic/components/select/select.ts @@ -126,6 +126,7 @@ export class Select { private _texts: Array = []; private _text: string = ''; private _fn: Function; + private _isOpen: boolean = false; /** * @private @@ -185,14 +186,25 @@ export class Select { } } - /** - * @private - */ @HostListener('click', ['$event']) private _click(ev) { + if (ev.detail === 0) { + // do not continue if the click event came from a form submit + return; + } ev.preventDefault(); ev.stopPropagation(); + this._open(); + } + @HostListener('keyup.space', ['$event']) + private _keyup(ev) { + if (!this._isOpen) { + this._open(); + } + } + + private _open() { if (this._disabled) return; console.debug('select, open alert'); @@ -245,6 +257,11 @@ export class Select { }); this._nav.present(alert, alertOptions); + + this._isOpen = true; + alert.onDismiss(() => { + this._isOpen = false; + }); } diff --git a/ionic/components/select/test/multiple-value/index.ts b/ionic/components/select/test/multiple-value/index.ts index a199048781b..e5c036307b9 100644 --- a/ionic/components/select/test/multiple-value/index.ts +++ b/ionic/components/select/test/multiple-value/index.ts @@ -1,4 +1,5 @@ import {App, Page} from 'ionic-angular'; +import {Control, ControlGroup} from 'angular2/common'; @Page({ @@ -9,6 +10,7 @@ class E2EPage { carFeatures: Array; pets: Array; petOptions: Array<{text: string, value: string}>; + authForm: ControlGroup; constructor() { this.toppings = ['bacon', 'xcheese']; @@ -21,12 +23,21 @@ class E2EPage { { text: 'Honey Badger', value: 'honeybadger' }, { text: 'Pig', value: 'pig' }, ]; + + this.authForm = new ControlGroup({ + name: new Control(''), + select: new Control('') + }); } carChange(selectedValues) { console.log('carChange', selectedValues); } + onSubmit(data) { + console.log('onSubmit', data); + } + } diff --git a/ionic/components/select/test/multiple-value/main.html b/ionic/components/select/test/multiple-value/main.html index 7c0cbeb383c..d41eff00ace 100644 --- a/ionic/components/select/test/multiple-value/main.html +++ b/ionic/components/select/test/multiple-value/main.html @@ -52,4 +52,21 @@ pets: {{pets}}

+
+ + + + + + Select + + 1 + 2 + 3 + + + + +
+