Skip to content

Commit f99a34d

Browse files
authored
feat(label+labelGroup): update aria-labels to include label text (#8192)
* feat(label+labelGroup): update aria-labels to include editable label text * PR feedback from Eric
1 parent 0afb2a9 commit f99a34d

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

packages/react-core/src/components/Label/examples/LabelEditable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const LabelEditable: React.FunctionComponent = () => {
3131
onEditComplete={onEditComplete}
3232
isEditable
3333
editableProps={{
34-
'aria-label': 'Editable text',
34+
'aria-label': `Editable label with text ${labelText}`,
3535
id: 'editable-label'
3636
}}
3737
>
@@ -46,7 +46,7 @@ export const LabelEditable: React.FunctionComponent = () => {
4646
onEditComplete={onCompactEditComplete}
4747
isEditable
4848
editableProps={{
49-
'aria-label': 'Compact editable text',
49+
'aria-label': `Editable compact label with text ${compactLabelText}`,
5050
id: 'compact-editable-label'
5151
}}
5252
>

packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAdd.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {
1111
props: {
1212
isEditable: true,
1313
editableProps: {
14-
'aria-label': 'label editable text'
14+
'aria-label': 'Editable label with text Label 3'
1515
}
1616
},
1717
id: 2
@@ -24,7 +24,12 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {
2424

2525
const onEdit = (nextText: string, index: number) => {
2626
const copy = [...labels];
27-
copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id };
27+
const updatedProps = {
28+
...labels[index].props,
29+
editableProps: { 'aria-label': `Editable label with text ${nextText}` }
30+
};
31+
32+
copy[index] = { name: nextText, props: updatedProps, id: labels[index].id };
2833
setLabels(copy);
2934
};
3035

@@ -35,7 +40,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {
3540
props: {
3641
isEditable: true,
3742
editableProps: {
38-
'aria-label': 'label editable text'
43+
'aria-label': `Editable label with text New Label`
3944
}
4045
},
4146
id: idIndex

packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddDropdown.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => {
1616
props: {
1717
isEditable: true,
1818
editableProps: {
19-
'aria-label': 'label editable text'
19+
'aria-label': 'Editable label with text Label 3'
2020
}
2121
},
2222
id: 2
@@ -29,7 +29,12 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => {
2929

3030
const onEdit = (nextText: string, index: number) => {
3131
const copy = [...labels];
32-
copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id };
32+
const updatedProps = {
33+
...labels[index].props,
34+
editableProps: { 'aria-label': `Editable label with text ${nextText}` }
35+
};
36+
37+
copy[index] = { name: nextText, props: updatedProps, id: labels[index].id };
3338
setLabels(copy);
3439
};
3540

packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddModal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
4747
props: {
4848
isEditable: true,
4949
editableProps: {
50-
'aria-label': 'label editable text'
50+
'aria-label': 'Editable label with text Label 3'
5151
}
5252
},
5353
id: 6
@@ -60,7 +60,12 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
6060

6161
const onEdit = (nextText: string, index: number) => {
6262
const copy = [...labels];
63-
copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id };
63+
const updatedProps = {
64+
...labels[index].props,
65+
editableProps: { 'aria-label': `Editable label with text ${nextText}` }
66+
};
67+
68+
copy[index] = { name: nextText, props: updatedProps, id: labels[index].id };
6469
setLabels(copy);
6570
};
6671

@@ -81,7 +86,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
8186
isEditable: isEditable !== undefined ? isEditable : true,
8287
...(isEditable && {
8388
editableProps: {
84-
'aria-label': 'label editable text'
89+
'aria-label': `Editable label with text ${labelText || 'New Label'}`
8590
}
8691
})
8792
},

packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => {
1515
onEditComplete={newText => setLabel1(newText)}
1616
isEditable
1717
editableProps={{
18-
'aria-label': 'Editable text',
18+
'aria-label': `Editable label with text ${label1}`,
1919
id: 'editable-label-1'
2020
}}
2121
>
@@ -29,7 +29,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => {
2929
onEditComplete={newText => setLabel2(newText)}
3030
isEditable
3131
editableProps={{
32-
'aria-label': 'Editable text 2',
32+
'aria-label': `Editable label with text ${label2}`,
3333
id: 'editable-label-2'
3434
}}
3535
>
@@ -42,7 +42,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => {
4242
onEditComplete={newText => setLabel3(newText)}
4343
isEditable
4444
editableProps={{
45-
'aria-label': 'Editable text 3',
45+
'aria-label': `Editable label with text ${label3}`,
4646
id: 'editable-label-3'
4747
}}
4848
>

0 commit comments

Comments
 (0)