From 24fb2ca931caf0962e489a8ad125e111202fef5f Mon Sep 17 00:00:00 2001 From: Sohab Sk Date: Wed, 31 Jul 2024 20:59:52 +0530 Subject: [PATCH 1/3] feat(Dialog): added two optional props for the close button label and tip --- packages/gamut/src/Modals/Dialog.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/gamut/src/Modals/Dialog.tsx b/packages/gamut/src/Modals/Dialog.tsx index e2cfe79088..f32c90f3b7 100644 --- a/packages/gamut/src/Modals/Dialog.tsx +++ b/packages/gamut/src/Modals/Dialog.tsx @@ -25,6 +25,8 @@ export interface DialogProps extends ModalBaseProps { >; confirmCta: DialogButtonProps; cancelCta?: DialogButtonProps; + closeButtonLabel?: string; + closeButtonTipText?: string; } export const Dialog: React.FC = ({ @@ -36,6 +38,8 @@ export const Dialog: React.FC = ({ onRequestClose, image, size = 'small', + closeButtonLabel = 'Close Dialog', + closeButtonTipText = 'Close dialog', ...rest }) => { const onConfirm: DialogButtonProps['onClick'] = ( @@ -69,12 +73,12 @@ export const Dialog: React.FC = ({ From b67490e2f282e4a89e34a0570daf5baa240c350c Mon Sep 17 00:00:00 2001 From: Sohab Sk Date: Wed, 31 Jul 2024 22:02:30 +0530 Subject: [PATCH 2/3] feat(Dialog): removed aria-label from the close button --- packages/gamut/src/Modals/Dialog.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/gamut/src/Modals/Dialog.tsx b/packages/gamut/src/Modals/Dialog.tsx index f32c90f3b7..33933e7fea 100644 --- a/packages/gamut/src/Modals/Dialog.tsx +++ b/packages/gamut/src/Modals/Dialog.tsx @@ -25,7 +25,6 @@ export interface DialogProps extends ModalBaseProps { >; confirmCta: DialogButtonProps; cancelCta?: DialogButtonProps; - closeButtonLabel?: string; closeButtonTipText?: string; } @@ -38,7 +37,6 @@ export const Dialog: React.FC = ({ onRequestClose, image, size = 'small', - closeButtonLabel = 'Close Dialog', closeButtonTipText = 'Close dialog', ...rest }) => { @@ -73,7 +71,6 @@ export const Dialog: React.FC = ({ Date: Thu, 1 Aug 2024 12:03:50 +0530 Subject: [PATCH 3/3] test(Dialog): updated the test case to get the element by default label --- packages/gamut/src/Modals/__tests__/Dialog.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/gamut/src/Modals/__tests__/Dialog.test.tsx b/packages/gamut/src/Modals/__tests__/Dialog.test.tsx index a55f18acee..9c3fb890a4 100644 --- a/packages/gamut/src/Modals/__tests__/Dialog.test.tsx +++ b/packages/gamut/src/Modals/__tests__/Dialog.test.tsx @@ -20,6 +20,7 @@ const defaultProps = { children: 'Cancel', onClick: onCancel, }, + closeButtonTipText: 'Close Dialog', }; const renderView = setupRtl(Dialog, defaultProps); @@ -43,8 +44,9 @@ describe('Dialog', () => { it('requests closing the dialog when the close button is clicked', () => { const { view } = renderView(); + const ariaLabel = defaultProps.closeButtonTipText.split(' ')[0]; - fireEvent.click(view.getByLabelText('Close Dialog')); + fireEvent.click(view.getByLabelText(ariaLabel)); expect(onRequestClose.mock.calls.length).toBe(1); });