diff --git a/core/src/components/action-sheet-controller/action-sheet-controller.tsx b/core/src/components/action-sheet-controller/action-sheet-controller.tsx index 0e2f6de07a..26b5093012 100644 --- a/core/src/components/action-sheet-controller/action-sheet-controller.tsx +++ b/core/src/components/action-sheet-controller/action-sheet-controller.tsx @@ -1,4 +1,5 @@ import { Component, Listen, Method, Prop } from '@stencil/core'; + import { ActionSheetOptions } from '../../interface'; import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; diff --git a/core/src/components/action-sheet/action-sheet-interface.ts b/core/src/components/action-sheet/action-sheet-interface.ts index c059d1bf60..6d4128dddd 100644 --- a/core/src/components/action-sheet/action-sheet-interface.ts +++ b/core/src/components/action-sheet/action-sheet-interface.ts @@ -15,4 +15,3 @@ export interface ActionSheetButton { cssClass?: string | string[]; handler?: () => boolean | void; } - diff --git a/core/src/components/action-sheet/action-sheet.tsx b/core/src/components/action-sheet/action-sheet.tsx index 82f5133488..deb9e3de56 100644 --- a/core/src/components/action-sheet/action-sheet.tsx +++ b/core/src/components/action-sheet/action-sheet.tsx @@ -1,13 +1,14 @@ import { Component, Element, Event, EventEmitter, Listen, Method, Prop } from '@stencil/core'; + import { ActionSheetButton, Animation, AnimationBuilder, Color, Config, CssClassMap, Mode, OverlayEventDetail, OverlayInterface } from '../../interface'; import { BACKDROP, dismiss, eventMethod, isCancel, present } from '../../utils/overlays'; import { createColorClasses, getClassMap } from '../../utils/theme'; + import { iosEnterAnimation } from './animations/ios.enter'; import { iosLeaveAnimation } from './animations/ios.leave'; import { mdEnterAnimation } from './animations/md.enter'; import { mdLeaveAnimation } from './animations/md.leave'; - @Component({ tag: 'ion-action-sheet', styleUrls: { @@ -115,7 +116,6 @@ export class ActionSheet implements OverlayInterface { */ @Event({ eventName: 'ionActionSheetDidDismiss' }) didDismiss!: EventEmitter; - componentDidLoad() { this.ionActionSheetDidLoad.emit(); } @@ -174,7 +174,7 @@ export class ActionSheet implements OverlayInterface { return eventMethod(this.el, 'ionActionSheetWillDismiss', callback); } - protected buttonClick(button: ActionSheetButton) { + private buttonClick(button: ActionSheetButton) { const role = button.role; if (isCancel(role)) { this.dismiss(undefined, role); @@ -190,9 +190,13 @@ export class ActionSheet implements OverlayInterface { if (button && button.handler) { // a handler has been provided, execute it // pass the handler the values from the inputs - if (button.handler() === false) { - // if the return value of the handler is false then do not dismiss - return false; + try { + if (button.handler() === false) { + // if the return value of the handler is false then do not dismiss + return false; + } + } catch (e) { + console.error(e); } } return true; @@ -212,14 +216,11 @@ export class ActionSheet implements OverlayInterface { } render() { + // TODO: move to processedButtons const allButtons = this.buttons.map(b => { - if (typeof b === 'string') { - b = { text: b }; - } - if (!b.cssClass) { - b.cssClass = ''; - } - return b; + return (typeof b === 'string') + ? { text: b } + : b; }); const cancelButton = allButtons.find(b => b.role === 'cancel'); const buttons = allButtons.filter(b => b.role !== 'cancel'); @@ -229,14 +230,12 @@ export class ActionSheet implements OverlayInterface {