From 8148ca2f541b80f88e8ff904a193ede95b191c12 Mon Sep 17 00:00:00 2001 From: Donald Labaj Date: Mon, 6 Nov 2023 11:55:59 -0500 Subject: [PATCH 1/3] fix(battery): Added battery component aria label. --- packages/module/src/Battery/Battery.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/module/src/Battery/Battery.tsx b/packages/module/src/Battery/Battery.tsx index 32f1b650..43413672 100644 --- a/packages/module/src/Battery/Battery.tsx +++ b/packages/module/src/Battery/Battery.tsx @@ -62,7 +62,7 @@ const batteryLevels = (severity: BatterySeverity, classMode?: boolean) => { case 'medium': case 'warn': case 2: - return classMode ? 'batteryMedium' : ; + return classMode ? 'batteryMedium' : ; case 'low': case 'info': case 1: @@ -91,17 +91,15 @@ const Battery: React.FunctionComponent = ({ severity, label, label const classes = useStyles(); const batteryClasses = clsx(classes.battery, classes[String(batteryLevels(severity, true))], className); - let ariaLabels = {}; - if (labelHidden) { - ariaLabels = { ['aria-label']: `${severity} ${label}` }; - } + const ariaLabels = { ['aria-label']: `${severity} ${label}` }; + const batteryVariant = useMemo(() => batteryLevels(severity) , [ severity ]) return ( {/* eslint-disable-next-line react/no-unknown-property */} - + Date: Mon, 6 Nov 2023 12:33:02 -0500 Subject: [PATCH 2/3] fix(Ansible): Fixed Ansible supported a11y. --- packages/module/src/Ansible/Ansible.tsx | 2 +- .../__snapshots__/Ansible.test.tsx.snap | 4 ++ .../__snapshots__/Batery.test.tsx.snap | 41 +++++++++++++------ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/packages/module/src/Ansible/Ansible.tsx b/packages/module/src/Ansible/Ansible.tsx index 9ad53a37..13440199 100644 --- a/packages/module/src/Ansible/Ansible.tsx +++ b/packages/module/src/Ansible/Ansible.tsx @@ -71,7 +71,7 @@ const Ansible: React.FunctionComponent = ({ unsupported, className ); return ( - + @@ -319,9 +329,10 @@ exports[`Battery component should render correctly MediumBattery - 2 1`] = ` exports[`Battery component should render correctly MediumBattery - medium 1`] = `
@@ -351,9 +363,10 @@ exports[`Battery component should render correctly MediumBattery - medium 1`] = exports[`Battery component should render correctly MediumBattery - warn 1`] = `
@@ -383,9 +397,10 @@ exports[`Battery component should render correctly MediumBattery - warn 1`] = ` exports[`Battery component should render correctly NullBatery, default 1`] = `
Date: Mon, 6 Nov 2023 13:23:42 -0500 Subject: [PATCH 3/3] replaced aria-label with title --- packages/module/src/Ansible/Ansible.tsx | 2 +- .../__snapshots__/Ansible.test.tsx.snap | 8 ++--- packages/module/src/Battery/Battery.tsx | 6 ++-- .../__snapshots__/Batery.test.tsx.snap | 29 +++++++++---------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/packages/module/src/Ansible/Ansible.tsx b/packages/module/src/Ansible/Ansible.tsx index 13440199..8f50e66a 100644 --- a/packages/module/src/Ansible/Ansible.tsx +++ b/packages/module/src/Ansible/Ansible.tsx @@ -71,7 +71,7 @@ const Ansible: React.FunctionComponent = ({ unsupported, className ); return ( - + { case 'medium': case 'warn': case 2: - return classMode ? 'batteryMedium' : ; + return classMode ? 'batteryMedium' : ; case 'low': case 'info': case 1: @@ -91,7 +91,7 @@ const Battery: React.FunctionComponent = ({ severity, label, label const classes = useStyles(); const batteryClasses = clsx(classes.battery, classes[String(batteryLevels(severity, true))], className); - const ariaLabels = { ['aria-label']: `${severity} ${label}` }; + const title = { ['title']: `${severity} ${label}` }; const batteryVariant = useMemo(() => batteryLevels(severity) , [ severity ]) @@ -99,7 +99,7 @@ const Battery: React.FunctionComponent = ({ severity, label, label return ( {/* eslint-disable-next-line react/no-unknown-property */} - + @@ -31,8 +31,8 @@ exports[`Battery component API should hide label 1`] = ` exports[`Battery component should render correctly CriticalBattery - 4 1`] = `
@@ -64,8 +64,8 @@ exports[`Battery component should render correctly CriticalBattery - 4 1`] = ` exports[`Battery component should render correctly CriticalBattery - critical 1`] = `
@@ -97,8 +97,8 @@ exports[`Battery component should render correctly CriticalBattery - critical 1` exports[`Battery component should render correctly HighBattery - 3 1`] = `
@@ -130,8 +130,8 @@ exports[`Battery component should render correctly HighBattery - 3 1`] = ` exports[`Battery component should render correctly HighBattery - error 1`] = `
@@ -163,8 +163,8 @@ exports[`Battery component should render correctly HighBattery - error 1`] = ` exports[`Battery component should render correctly HighBattery - high 1`] = `
@@ -196,8 +196,8 @@ exports[`Battery component should render correctly HighBattery - high 1`] = ` exports[`Battery component should render correctly LowBattery - 1 1`] = `
@@ -229,8 +229,8 @@ exports[`Battery component should render correctly LowBattery - 1 1`] = ` exports[`Battery component should render correctly LowBattery - info 1`] = `
@@ -262,8 +262,8 @@ exports[`Battery component should render correctly LowBattery - info 1`] = ` exports[`Battery component should render correctly LowBattery - low 1`] = `
@@ -295,8 +295,8 @@ exports[`Battery component should render correctly LowBattery - low 1`] = ` exports[`Battery component should render correctly MediumBattery - 2 1`] = `
@@ -314,7 +314,6 @@ exports[`Battery component should render correctly MediumBattery - 2 1`] = ` /> @@ -329,8 +328,8 @@ exports[`Battery component should render correctly MediumBattery - 2 1`] = ` exports[`Battery component should render correctly MediumBattery - medium 1`] = `
@@ -348,7 +347,6 @@ exports[`Battery component should render correctly MediumBattery - medium 1`] = /> @@ -363,8 +361,8 @@ exports[`Battery component should render correctly MediumBattery - medium 1`] = exports[`Battery component should render correctly MediumBattery - warn 1`] = `
@@ -382,7 +380,6 @@ exports[`Battery component should render correctly MediumBattery - warn 1`] = ` /> @@ -397,8 +394,8 @@ exports[`Battery component should render correctly MediumBattery - warn 1`] = ` exports[`Battery component should render correctly NullBatery, default 1`] = `