Skip to content

Commit

Permalink
feat(label+labelGroup): update aria-labels to include label text (#8192)
Browse files Browse the repository at this point in the history
* feat(label+labelGroup): update aria-labels to include editable label text

* PR feedback from Eric
  • Loading branch information
jenny-s51 authored Oct 13, 2022
1 parent 0afb2a9 commit f99a34d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const LabelEditable: React.FunctionComponent = () => {
onEditComplete={onEditComplete}
isEditable
editableProps={{
'aria-label': 'Editable text',
'aria-label': `Editable label with text ${labelText}`,
id: 'editable-label'
}}
>
Expand All @@ -46,7 +46,7 @@ export const LabelEditable: React.FunctionComponent = () => {
onEditComplete={onCompactEditComplete}
isEditable
editableProps={{
'aria-label': 'Compact editable text',
'aria-label': `Editable compact label with text ${compactLabelText}`,
id: 'compact-editable-label'
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {
props: {
isEditable: true,
editableProps: {
'aria-label': 'label editable text'
'aria-label': 'Editable label with text Label 3'
}
},
id: 2
Expand All @@ -24,7 +24,12 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {

const onEdit = (nextText: string, index: number) => {
const copy = [...labels];
copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id };
const updatedProps = {
...labels[index].props,
editableProps: { 'aria-label': `Editable label with text ${nextText}` }
};

copy[index] = { name: nextText, props: updatedProps, id: labels[index].id };
setLabels(copy);
};

Expand All @@ -35,7 +40,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {
props: {
isEditable: true,
editableProps: {
'aria-label': 'label editable text'
'aria-label': `Editable label with text New Label`
}
},
id: idIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => {
props: {
isEditable: true,
editableProps: {
'aria-label': 'label editable text'
'aria-label': 'Editable label with text Label 3'
}
},
id: 2
Expand All @@ -29,7 +29,12 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => {

const onEdit = (nextText: string, index: number) => {
const copy = [...labels];
copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id };
const updatedProps = {
...labels[index].props,
editableProps: { 'aria-label': `Editable label with text ${nextText}` }
};

copy[index] = { name: nextText, props: updatedProps, id: labels[index].id };
setLabels(copy);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
props: {
isEditable: true,
editableProps: {
'aria-label': 'label editable text'
'aria-label': 'Editable label with text Label 3'
}
},
id: 6
Expand All @@ -60,7 +60,12 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {

const onEdit = (nextText: string, index: number) => {
const copy = [...labels];
copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id };
const updatedProps = {
...labels[index].props,
editableProps: { 'aria-label': `Editable label with text ${nextText}` }
};

copy[index] = { name: nextText, props: updatedProps, id: labels[index].id };
setLabels(copy);
};

Expand All @@ -81,7 +86,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
isEditable: isEditable !== undefined ? isEditable : true,
...(isEditable && {
editableProps: {
'aria-label': 'label editable text'
'aria-label': `Editable label with text ${labelText || 'New Label'}`
}
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => {
onEditComplete={newText => setLabel1(newText)}
isEditable
editableProps={{
'aria-label': 'Editable text',
'aria-label': `Editable label with text ${label1}`,
id: 'editable-label-1'
}}
>
Expand All @@ -29,7 +29,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => {
onEditComplete={newText => setLabel2(newText)}
isEditable
editableProps={{
'aria-label': 'Editable text 2',
'aria-label': `Editable label with text ${label2}`,
id: 'editable-label-2'
}}
>
Expand All @@ -42,7 +42,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => {
onEditComplete={newText => setLabel3(newText)}
isEditable
editableProps={{
'aria-label': 'Editable text 3',
'aria-label': `Editable label with text ${label3}`,
id: 'editable-label-3'
}}
>
Expand Down

0 comments on commit f99a34d

Please sign in to comment.