From 5ce4ec0439e4f31aba31062fd8af4a2ad792a54f Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Mon, 31 Jul 2023 12:23:46 -0400 Subject: [PATCH] feat(action-sheet): add htmlAttributes property for passing attributes to buttons (#27863) Issue number: N/A --------- ## What is the current behavior? Buttons containing only icons are not accessible as there is no way to pass an `aria-label` attribute (or any other html attribute). ## What is the new behavior? - Adds the `htmlAttributes` property on the `ActionSheetButton` interface - Passes the `htmlAttributes` to the buttons (both the buttons array and the cancelButton) - Adds two tests to verify `aria-label` and `aria-labelled-by` are passed to a button with and without the cancel role - this was done because action sheet breaks these buttons up when rendering ## Does this introduce a breaking change? - [ ] Yes - [x] No --- .../action-sheet/action-sheet-interface.ts | 1 + .../components/action-sheet/action-sheet.tsx | 15 +++++++- .../test/a11y/action-sheet.e2e.ts | 36 +++++++++++++++++- .../action-sheet/test/a11y/index.html | 37 +++++++++++++++++++ 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/core/src/components/action-sheet/action-sheet-interface.ts b/core/src/components/action-sheet/action-sheet-interface.ts index 9428b59b01..465c50e050 100644 --- a/core/src/components/action-sheet/action-sheet-interface.ts +++ b/core/src/components/action-sheet/action-sheet-interface.ts @@ -23,6 +23,7 @@ export interface ActionSheetButton { icon?: string; cssClass?: string | string[]; id?: string; + htmlAttributes?: { [key: string]: any }; handler?: () => boolean | void | Promise; data?: T; } diff --git a/core/src/components/action-sheet/action-sheet.tsx b/core/src/components/action-sheet/action-sheet.tsx index 9a877054cf..e6854c8fdd 100644 --- a/core/src/components/action-sheet/action-sheet.tsx +++ b/core/src/components/action-sheet/action-sheet.tsx @@ -386,7 +386,13 @@ export class ActionSheet implements ComponentInterface, OverlayInterface { )} {buttons.map((b) => ( -