Skip to content

Commit da06afe

Browse files
author
Kubit
committed
Update dataTestId for options
1 parent 8560da8 commit da06afe

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/components/oliveMenu/__test__/oliveMenu.utils.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getAriaControls } from '../utils';
44
const menuSection: OliveMenuListOptions[] = [
55
{
66
title: { content: 'label1' },
7-
id: '1',
7+
id: 'number1',
88
options: [
99
{
1010
label: 'option 1',
@@ -25,7 +25,7 @@ const menuSection: OliveMenuListOptions[] = [
2525
},
2626
{
2727
title: { content: 'label2' },
28-
id: '2',
28+
id: 'number2',
2929
options: [
3030
{
3131
label: 'option 1',
@@ -48,7 +48,7 @@ const menuSection: OliveMenuListOptions[] = [
4848
describe('Olive Menu utils', () => {
4949
test('Should get ariaControls', async () => {
5050
expect(getAriaControls(menuSection, 'ariaControls')).toStrictEqual(
51-
'ariaControls0 ariaControls1'
51+
'ariaControls0number1 ariaControls1number2'
5252
);
5353
});
5454
});

src/components/oliveMenu/oliveMenuStandAlone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const OliveMenuStandAloneComponent = (
9393
<ListOptions
9494
key={section.id}
9595
dataTestId={props.dataTestId}
96-
id={`${ariaControls}${index}`}
96+
id={`${ariaControls}${index}${section.id ? `${section.id}` : ''}`}
9797
optionVariant={props.styles.listOptions?.optionVariant as string}
9898
selectedValue={props.selectedValue}
9999
title={{ component: TextComponentType.H6, ...title }}

src/components/oliveMenu/stories/oliveMenu.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Story = StoryObj<typeof meta> & { args: { themeArgs?: object } };
2929
const sections: OliveMenuListOptions[] = [
3030
{
3131
title: { content: 'list 1' },
32+
id: 'ID_1',
3233
options: [
3334
{
3435
label: 'option 1',
@@ -48,6 +49,7 @@ const sections: OliveMenuListOptions[] = [
4849
},
4950
{
5051
title: { content: 'list 2' },
52+
id: 'ID_2',
5153
options: [
5254
{
5355
label: 'option 1',

src/components/oliveMenu/utils/getAriaControls.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export const getAriaControls = (
55
ariaControls: string
66
): string => {
77
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+
);
912
return newAriaControls.trimStart();
1013
};

0 commit comments

Comments
 (0)