From 33c1fcf044e31ed80fdc4746a7f092e9fe33011c Mon Sep 17 00:00:00 2001 From: Avinash Dwarapu Date: Tue, 4 Feb 2025 17:04:57 +0100 Subject: [PATCH] Replace internal usages. --- src/alert/__tests__/alert.test.tsx | 4 ++-- src/alert/internal.tsx | 4 ++-- src/button/internal.tsx | 11 +++++------ src/flashbar/collapsible-flashbar.tsx | 6 ++---- src/flashbar/flash.tsx | 25 ++++++++++++------------ src/form-field/internal.tsx | 8 ++++---- src/table/__tests__/header-cell.test.tsx | 5 ++++- src/table/body-cell/index.tsx | 4 +--- src/table/header-cell/index.tsx | 11 +++++------ 9 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/alert/__tests__/alert.test.tsx b/src/alert/__tests__/alert.test.tsx index 6762b284a7..ff89b3b9d8 100644 --- a/src/alert/__tests__/alert.test.tsx +++ b/src/alert/__tests__/alert.test.tsx @@ -85,7 +85,7 @@ describe('Alert Component', () => { }); it('status icon does not have a label by default', () => { const { wrapper } = renderAlert({}); - expect(wrapper.find('[role="img"]')!.getElement()).not.toHaveAttribute('aria-label'); + expect(wrapper.find('[role="img"]')).toBeNull(); }); it('status icon can have a label', () => { const { wrapper } = renderAlert({ i18nStrings }); @@ -215,7 +215,7 @@ describe('Alert Component', () => { ); const wrapper = createWrapper(container)!.findAlert()!; - const statusIcon = wrapper.findByClassName(styles.icon)!.getElement(); + const statusIcon = wrapper.findByClassName(styles.icon)!.findIcon()!.getElement(); const dismissButton = wrapper.findDismissButton()!.getElement(); return { statusIcon, dismissButton }; } diff --git a/src/alert/internal.tsx b/src/alert/internal.tsx index bd60f29f26..4a62ddadbf 100644 --- a/src/alert/internal.tsx +++ b/src/alert/internal.tsx @@ -132,8 +132,8 @@ const InternalAlert = React.forwardRef( )} >
-
- +
+
  - - - + )} diff --git a/src/flashbar/collapsible-flashbar.tsx b/src/flashbar/collapsible-flashbar.tsx index 68dc1a18b4..59e0d075a3 100644 --- a/src/flashbar/collapsible-flashbar.tsx +++ b/src/flashbar/collapsible-flashbar.tsx @@ -372,10 +372,8 @@ const NotificationTypeCount = ({ }) => { return ( - - + + {count} diff --git a/src/flashbar/flash.tsx b/src/flashbar/flash.tsx index f84d20fa26..813c9692b9 100644 --- a/src/flashbar/flash.tsx +++ b/src/flashbar/flash.tsx @@ -134,9 +134,18 @@ export const Flash = React.forwardRef( const headerRef = useMergeRefs(headerRefAction, headerRefContent, headerRefObject); const contentRef = useMergeRefs(contentRefAction, contentRefContent, contentRefObject); - const iconType = ICON_TYPES[type]; + const statusIconAriaLabel = + props.statusIconAriaLabel || + i18nStrings?.[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`]; - const icon = loading ? : ; + const iconType = ICON_TYPES[type]; + const icon = loading ? ( + + + + ) : ( + + ); const effectiveType = loading ? 'info' : type; @@ -144,10 +153,6 @@ export const Flash = React.forwardRef( [DATA_ATTR_ANALYTICS_FLASHBAR]: effectiveType, }; - const statusIconAriaLabel = - props.statusIconAriaLabel || - i18nStrings?.[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`]; - return ( // We're not using "polite" or "assertive" here, just turning default behavior off. // eslint-disable-next-line @cloudscape-design/prefer-live-region @@ -175,13 +180,7 @@ export const Flash = React.forwardRef( >
-
- {icon} -
+
{icon}
-
- +
+
@@ -75,8 +75,8 @@ export function FormFieldWarning({ id, children, warningIconAriaLabel }: FormFie <>
-
- +
+
diff --git a/src/table/__tests__/header-cell.test.tsx b/src/table/__tests__/header-cell.test.tsx index 8056b17384..fe80872a06 100644 --- a/src/table/__tests__/header-cell.test.tsx +++ b/src/table/__tests__/header-cell.test.tsx @@ -119,7 +119,10 @@ describe('i18n', () => { ); - expect(container.querySelector(`.${styles['edit-icon']}`)).toHaveAttribute('aria-label', 'Custom editable'); + expect(container.querySelector(`.${styles['edit-icon']} [role=img]`)).toHaveAttribute( + 'aria-label', + 'Custom editable' + ); }); test('does not set tab index when negative', () => { diff --git a/src/table/body-cell/index.tsx b/src/table/body-cell/index.tsx index d45f2c3fdc..2c8d2f17db 100644 --- a/src/table/body-cell/index.tsx +++ b/src/table/body-cell/index.tsx @@ -104,15 +104,13 @@ function TableCellEditable({ <> { // Prevent the editor's Button blur event to be fired when clicking the success icon. // This prevents unfocusing the button and triggers the `TableTdElement` onClick event which initiates the edit mode. e.preventDefault(); }} > - +