From 06be0e511164ebdaa6af9a3747d0585260c030a9 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Mon, 31 Jul 2023 13:16:17 -0400 Subject: [PATCH] feat(alert): add htmlAttributes property for passing attributes to buttons (#27862) 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 `AlertButton` interface - Passes the `htmlAttributes` to the buttons - Adds a test to verify `aria-label` and `aria-labelled-by` are passed to the button ## Does this introduce a breaking change? - [ ] Yes - [x] No --- core/src/components/alert/alert-interface.ts | 1 + core/src/components/alert/alert.tsx | 1 + .../components/alert/test/a11y/alert.e2e.ts | 16 ++++++++++++++++ core/src/components/alert/test/a11y/index.html | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/core/src/components/alert/alert-interface.ts b/core/src/components/alert/alert-interface.ts index f6e04499b1..3f9d6cda8d 100644 --- a/core/src/components/alert/alert-interface.ts +++ b/core/src/components/alert/alert-interface.ts @@ -48,6 +48,7 @@ export interface AlertButton { role?: 'cancel' | 'destructive' | string; cssClass?: string | string[]; id?: string; + htmlAttributes?: { [key: string]: any }; // TODO(FW-2832): type handler?: (value: any) => AlertButtonOverlayHandler | Promise; } diff --git a/core/src/components/alert/alert.tsx b/core/src/components/alert/alert.tsx index 8ce5094492..4b89c605f6 100644 --- a/core/src/components/alert/alert.tsx +++ b/core/src/components/alert/alert.tsx @@ -666,6 +666,7 @@ export class Alert implements ComponentInterface, OverlayInterface {
{buttons.map((button) => (