From 7331bf499fada215663d751efab033efdaccf31a Mon Sep 17 00:00:00 2001 From: mhartington Date: Thu, 10 Aug 2017 10:14:57 -0400 Subject: [PATCH] fix(actionSheet): render cancel button in different group --- .../components/action-sheet/action-sheet.tsx | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/packages/core/src/components/action-sheet/action-sheet.tsx b/packages/core/src/components/action-sheet/action-sheet.tsx index 85da0152d8..89399ac839 100644 --- a/packages/core/src/components/action-sheet/action-sheet.tsx +++ b/packages/core/src/components/action-sheet/action-sheet.tsx @@ -147,6 +147,22 @@ export class ActionSheet { userCssClass += ' ' + this.cssClass; } + let cancelButton: ActionSheetButton; + let buttons = this.buttons + .map(b => { + if (typeof b === 'string') { + b = { text: b }; + } + if (!b.cssClass) { + b.cssClass = ''; + } + if (b.role === 'cancel') { + cancelButton = b; + return null; + } + return b; + }) + .filter(b => b !== null); return [ {this.subTitle} : null} - {this.buttons.map(b => - )} + {cancelButton + ?
+ + +
+ : null} ]; @@ -179,13 +211,12 @@ export class ActionSheet { buttonClass(button: ActionSheetButton): CssClassMap { let buttonClass: string[] = !button.role ? ['action-sheet-button'] - : [`action-sheet-button`, `action-sheet-${button.role}`] + : [`action-sheet-button`, `action-sheet-${button.role}`]; return buttonClass.reduce((prevValue: any, cssClass: any) => { prevValue[cssClass] = true; return prevValue; }, {}); } - } export interface ActionSheetOptions {