Skip to content

Commit

Permalink
Merge pull request #153 from unicef/fix/accessibility-badge-status
Browse files Browse the repository at this point in the history
Fix aria-live and role for UAsyncBadge
  • Loading branch information
vinuganesan authored Mar 12, 2024
2 parents cc448cb + 3cf2836 commit ff0ca6b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unicef/material-ui",
"version": "0.12.3",
"version": "0.12.4",
"description": "UNICEF theme and components of material-ui for react",
"main": "index.js",
"files": [
Expand Down
22 changes: 19 additions & 3 deletions src/components/UAsyncBadge/UAsyncBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ const useStyles = makeStyles(theme => ({
/**
* UAsyncBadge is a component to display async operation status perform in the application
*/
export default function UAsyncBadge({ variant, text, visible, onReset }) {
export default function UAsyncBadge({
variant,
text,
visible,
ariaRole,
ariaLive,
onReset,
}) {
const classes = useStyles()
const chipRef = useRef()

Expand All @@ -50,8 +57,8 @@ export default function UAsyncBadge({ variant, text, visible, onReset }) {
{visible && (
<Chip
ref={chipRef}
role="status"
aria-live="polite"
role={ariaRole}
aria-live={ariaLive}
className={`${classes.chip} ${classes[variant]}`}
avatar={
variant === 'loading' ? (
Expand Down Expand Up @@ -80,4 +87,13 @@ UAsyncBadge.propTypes = {
visible: PropTypes.bool,
/** trigger reset of the badge */
onReset: PropTypes.func,
/** Aria role of the badge */
ariaRole: PropTypes.oneOf(['log', 'status', 'alert']),
/** Aria live of the badge */
ariaLive: PropTypes.oneOf(['polite', 'assertive', 'off']),
}

UAsyncBadge.defaultTypes = {
ariaRole: 'alert',
ariaLive: 'assertive',
}

0 comments on commit ff0ca6b

Please sign in to comment.