diff --git a/ionic/components/action-sheet/action-sheet.ts b/ionic/components/action-sheet/action-sheet.ts index 57f3bd9d6e..376b3925c8 100644 --- a/ionic/components/action-sheet/action-sheet.ts +++ b/ionic/components/action-sheet/action-sheet.ts @@ -4,6 +4,7 @@ import {NgFor, NgIf} from 'angular2/common'; import {Animation} from '../../animations/animation'; import {Config} from '../../config/config'; import {Icon} from '../icon/icon'; +import {isDefined} from '../../util/util'; import {NavParams} from '../nav/nav-params'; import {ViewController} from '../nav/view-controller'; @@ -82,9 +83,11 @@ import {ViewController} from '../nav/view-controller'; title?: string, subTitle?: string, cssClass?: string, + enableBackdropDismiss?: boolean, buttons?: Array } = {}) { opts.buttons = opts.buttons || []; + opts.enableBackdropDismiss = isDefined(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true; super(ActionSheetCmp, opts); this.viewType = 'action-sheet'; @@ -242,11 +245,13 @@ class ActionSheetCmp { } bdClick() { - if (this.d.cancelButton) { - this.click(this.d.cancelButton, 1); + if (this.d.enableBackdropDismiss) { + if (this.d.cancelButton) { + this.click(this.d.cancelButton, 1); - } else { - this.dismiss('backdrop'); + } else { + this.dismiss('backdrop'); + } } } @@ -254,7 +259,11 @@ class ActionSheetCmp { return this._viewCtrl.dismiss(null, role); } - onPageDidLeave() { + onPageWillLeave() { + document.removeEventListener('keyup', this.keyUp); + } + + ngOnDestroy() { document.removeEventListener('keyup', this.keyUp); } } diff --git a/ionic/components/action-sheet/test/basic/index.ts b/ionic/components/action-sheet/test/basic/index.ts index 10ac709180..0c86f08c4b 100644 --- a/ionic/components/action-sheet/test/basic/index.ts +++ b/ionic/components/action-sheet/test/basic/index.ts @@ -57,6 +57,7 @@ class E2EPage { this.result = ''; let actionSheet = ActionSheet.create({ + enableBackdropDismiss: false, buttons: [ { text: 'Archive', diff --git a/ionic/components/alert/alert.ts b/ionic/components/alert/alert.ts index 4730c07462..0827ddbad8 100644 --- a/ionic/components/alert/alert.ts +++ b/ionic/components/alert/alert.ts @@ -137,7 +137,7 @@ export class Alert extends ViewController { } = {}) { opts.inputs = opts.inputs || []; opts.buttons = opts.buttons || []; - opts.enableBackdropDismiss = (opts.enableBackdropDismiss === false ? false : true); + opts.enableBackdropDismiss = isDefined(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true; super(AlertCmp, opts); this.viewType = 'alert';