File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { getAriaControls } from '../utils';
4
4
const menuSection : OliveMenuListOptions [ ] = [
5
5
{
6
6
title : { content : 'label1' } ,
7
- id : '1 ' ,
7
+ id : 'number1 ' ,
8
8
options : [
9
9
{
10
10
label : 'option 1' ,
@@ -25,7 +25,7 @@ const menuSection: OliveMenuListOptions[] = [
25
25
} ,
26
26
{
27
27
title : { content : 'label2' } ,
28
- id : '2 ' ,
28
+ id : 'number2 ' ,
29
29
options : [
30
30
{
31
31
label : 'option 1' ,
@@ -48,7 +48,7 @@ const menuSection: OliveMenuListOptions[] = [
48
48
describe ( 'Olive Menu utils' , ( ) => {
49
49
test ( 'Should get ariaControls' , async ( ) => {
50
50
expect ( getAriaControls ( menuSection , 'ariaControls' ) ) . toStrictEqual (
51
- 'ariaControls0 ariaControls1 '
51
+ 'ariaControls0number1 ariaControls1number2 '
52
52
) ;
53
53
} ) ;
54
54
} ) ;
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ const OliveMenuStandAloneComponent = (
93
93
< ListOptions
94
94
key = { section . id }
95
95
dataTestId = { props . dataTestId }
96
- id = { `${ ariaControls } ${ index } ` }
96
+ id = { `${ ariaControls } ${ index } ${ section . id ? ` ${ section . id } ` : '' } ` }
97
97
optionVariant = { props . styles . listOptions ?. optionVariant as string }
98
98
selectedValue = { props . selectedValue }
99
99
title = { { component : TextComponentType . H6 , ...title } }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ type Story = StoryObj<typeof meta> & { args: { themeArgs?: object } };
29
29
const sections : OliveMenuListOptions [ ] = [
30
30
{
31
31
title : { content : 'list 1' } ,
32
+ id : 'ID_1' ,
32
33
options : [
33
34
{
34
35
label : 'option 1' ,
@@ -48,6 +49,7 @@ const sections: OliveMenuListOptions[] = [
48
49
} ,
49
50
{
50
51
title : { content : 'list 2' } ,
52
+ id : 'ID_2' ,
51
53
options : [
52
54
{
53
55
label : 'option 1' ,
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ export const getAriaControls = (
5
5
ariaControls : string
6
6
) : string => {
7
7
let newAriaControls = '' ;
8
- sections ?. forEach ( ( _section , index ) => ( newAriaControls += ` ${ ariaControls } ${ index } ` ) ) ;
8
+ sections ?. forEach (
9
+ ( _section , index ) =>
10
+ ( newAriaControls += ` ${ ariaControls } ${ index } ${ _section . id ? `${ _section . id } ` : '' } ` )
11
+ ) ;
9
12
return newAriaControls . trimStart ( ) ;
10
13
} ;
You can’t perform that action at this time.
0 commit comments