Skip to content

Commit ca26edc

Browse files
committed
fix:Added aria description to EditableInput
1 parent 3d42322 commit ca26edc

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

client/modules/IDE/components/EditableInput.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function EditableInput({
1313
inputProps,
1414
onChange,
1515
disabled,
16+
description,
1617
'aria-label': ariaLabel
1718
}) {
1819
const [isEditing, setIsEditing] = React.useState(false);
@@ -26,6 +27,14 @@ function EditableInput({
2627
}`;
2728
const inputRef = React.useRef();
2829
const { t } = useTranslation();
30+
const inputLabel =
31+
description ??
32+
ariaLabel ??
33+
t('EditableInput.EditValue', { display: displayValue });
34+
const buttonLabel =
35+
ariaLabel ??
36+
description ??
37+
t('EditableInput.EditValue', { display: displayValue });
2938
React.useEffect(() => {
3039
if (isEditing) {
3140
const inputElement = inputRef.current;
@@ -78,9 +87,7 @@ function EditableInput({
7887
<button
7988
className="editable-input__label"
8089
onClick={beginEditing}
81-
aria-label={
82-
ariaLabel ?? t('EditableInput.EditValue', { display: displayValue })
83-
}
90+
aria-label={buttonLabel}
8491
aria-hidden={isEditing}
8592
disabled={disabled}
8693
>
@@ -98,6 +105,7 @@ function EditableInput({
98105
{...inputProps}
99106
disabled={!isEditing}
100107
aria-hidden={!isEditing}
108+
aria-label={inputLabel}
101109
onBlur={doneEditing}
102110
onChange={updateValue}
103111
onKeyDown={checkForKeyAction}
@@ -115,6 +123,7 @@ EditableInput.defaultProps = {
115123
validate: () => true,
116124
value: '',
117125
disabled: false,
126+
description: undefined,
118127
'aria-label': undefined
119128
};
120129

@@ -127,6 +136,7 @@ EditableInput.propTypes = {
127136
validate: PropTypes.func,
128137
value: PropTypes.string,
129138
disabled: PropTypes.bool,
139+
description: PropTypes.string,
130140
'aria-label': PropTypes.string
131141
};
132142

client/modules/IDE/components/Header/ProjectName.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export default function ProjectName() {
1616
<EditableInput
1717
value={projectName}
1818
disabled={!canEditProjectName}
19+
description={t('Toolbar.NewSketchNameARIA')}
1920
aria-label={t('Toolbar.EditSketchARIA')}
2021
inputProps={{
21-
maxLength: 128,
22-
'aria-label': t('Toolbar.NewSketchNameARIA')
22+
maxLength: 128
2323
}}
2424
validate={(text) => text.trim().length > 0}
2525
onChange={changeSketchName}

client/modules/User/components/CollectionMetadata.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function CollectionMetadata({ collectionId }) {
6363
<EditableInput
6464
value={name}
6565
onChange={handleEditCollectionName}
66+
aria-label={t('Collection.NameARIA')}
6667
validate={(value) => value !== ''}
6768
/>
6869
) : (
@@ -76,6 +77,7 @@ function CollectionMetadata({ collectionId }) {
7677
InputComponent="textarea"
7778
value={description}
7879
onChange={handleEditCollectionDescription}
80+
aria-label={t('Collection.DescriptionARIA')}
7981
emptyPlaceholder={t('Collection.DescriptionPlaceholder')}
8082
/>
8183
) : (

translations/locales/en-US/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@
509509
},
510510
"Collection": {
511511
"Title": "p5.js Web Editor | My collections",
512+
"NameARIA": "Collection Name",
513+
"DescriptionARIA": "Collection Description",
512514
"AnothersTitle": "p5.js Web Editor | {{anotheruser}}'s collections",
513515
"Share": "Share",
514516
"URLLink": "Link to Collection",
@@ -566,6 +568,7 @@
566568
"HeaderCreatedAt": "Date Created",
567569
"HeaderCreatedAt_mobile": "Created",
568570
"HeaderUpdatedAt": "Date Updated",
571+
"EditCollectionARIA": "Edit Collection name",
569572
"HeaderUpdatedAt_mobile": "Updated",
570573
"HeaderNumItems": "# sketches",
571574
"HeaderNumItems_mobile": "# sketches",

0 commit comments

Comments
 (0)