From 78642c2e19e5e5081459b4e53720a43ab74efda2 Mon Sep 17 00:00:00 2001 From: luisbytes Date: Wed, 2 Aug 2023 22:21:22 -0500 Subject: [PATCH 1/2] feat(toast): add part for button cancel --- core/api.txt | 1 + .../components/toast/test/buttons/toast.e2e.ts | 16 ++++++++++++++++ core/src/components/toast/toast.tsx | 13 ++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 core/src/components/toast/test/buttons/toast.e2e.ts diff --git a/core/api.txt b/core/api.txt index 55ace969a9a..77a12c3b805 100644 --- a/core/api.txt +++ b/core/api.txt @@ -1471,6 +1471,7 @@ ion-toast,css-prop,--start ion-toast,css-prop,--white-space ion-toast,css-prop,--width ion-toast,part,button +ion-toast,part,button-cancel ion-toast,part,container ion-toast,part,header ion-toast,part,icon diff --git a/core/src/components/toast/test/buttons/toast.e2e.ts b/core/src/components/toast/test/buttons/toast.e2e.ts new file mode 100644 index 00000000000..9dbddbf2901 --- /dev/null +++ b/core/src/components/toast/test/buttons/toast.e2e.ts @@ -0,0 +1,16 @@ +import { expect } from '@playwright/test'; +import { configs, test } from '@utils/test/playwright'; + +configs().forEach(({ title, config }) => { + test.describe(title('toast: cancel button'), () => { + test('should render the cancel button with part button-cancel', async ({ page }) => { + await page.goto('/src/components/toast/test/buttons', config); + + const toast = page.locator('#closeArray'); + await toast.click(); + + const buttonCancel = page.locator('.toast-button-cancel'); + await expect(buttonCancel).toHaveAttribute('part', 'button-cancel'); + }); + }); +}); diff --git a/core/src/components/toast/toast.tsx b/core/src/components/toast/toast.tsx index 4f397d94a7c..1d344f50a22 100644 --- a/core/src/components/toast/toast.tsx +++ b/core/src/components/toast/toast.tsx @@ -34,6 +34,7 @@ import type { ToastButton, ToastPosition, ToastLayout } from './toast-interface' * @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use. * * @part button - Any button element that is displayed inside of the toast. + * @part button-cancel - Any button element with role "cancel" that is displayed inside of the toast. * @part container - The element that wraps all child elements. * @part header - The header text of the toast. * @part message - The body text of the toast. @@ -405,7 +406,13 @@ export class Toast implements ComponentInterface, OverlayInterface { return (
{buttons.map((b) => ( -