Skip to content

Commit e86d6cc

Browse files
committed
feat(@clayui/vertical-nav): LPD-46396 - Include an aria-label property on the Clay Vertical Navigation component and ensure its proper implementation in usage.
1 parent 6456669 commit e86d6cc

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/clay-core/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"fuzzy": "^0.1.3",
4141
"react-dnd": "^11.1.1",
4242
"react-dnd-html5-backend": "^11.1.1",
43-
"react-transition-group": "^4.4.1"
43+
"react-transition-group": "^4.4.1",
44+
"warning": "^4.0.3"
4445
},
4546
"peerDependencies": {
4647
"@clayui/css": "3.x",

packages/clay-core/src/vertical-nav/VerticalNav.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
useNavigation,
1212
} from '@clayui/shared';
1313
import classNames from 'classnames';
14-
import React, {useCallback, useMemo, useRef, useState} from 'react';
14+
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
15+
import warning from 'warning';
1516

1617
import {Collection, useCollection} from '../collection';
1718
import {Nav} from '../nav';
@@ -49,6 +50,11 @@ type Props<T extends Record<string, any> | string> = {
4950
*/
5051
activation?: 'manual' | 'automatic';
5152

53+
/**
54+
* Flag to define aria-label.
55+
*/
56+
'aria-label': string;
57+
5258
/**
5359
* The component contents.
5460
*/
@@ -140,6 +146,7 @@ function VerticalNav<T extends Record<string, any> | string>(
140146
function VerticalNav<T extends Record<string, any> | string>({
141147
active,
142148
activation = 'manual',
149+
'aria-label': ariaLabel,
143150
children,
144151
decorated,
145152
displayType,
@@ -275,8 +282,16 @@ function VerticalNav<T extends Record<string, any> | string>({
275282
</Nav>
276283
);
277284

285+
useEffect(() => {
286+
warning(
287+
ariaLabel,
288+
"[VerticalNav]: Missing required 'aria-label' attribute. Please provide a value to ensure accessibility."
289+
);
290+
}, [ariaLabel]);
291+
278292
return (
279293
<nav
294+
aria-label={ariaLabel}
280295
className={classNames('menubar menubar-transparent', {
281296
['menubar-decorated']: decorated,
282297
['menubar-primary']: displayType === 'primary',

0 commit comments

Comments
 (0)