Skip to content

Commit 5935d97

Browse files
committed
fix:Added aria description to EditableInput
1 parent bfe708c commit 5935d97

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

client/modules/IDE/components/EditableInput.jsx

Lines changed: 9 additions & 4 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,10 @@ function EditableInput({
2627
}`;
2728
const inputRef = React.useRef();
2829
const { t } = useTranslation();
30+
const label =
31+
description ??
32+
ariaLabel ??
33+
t('EditableInput.EditValue', { display: displayValue });
2934
React.useEffect(() => {
3035
if (isEditing) {
3136
const inputElement = inputRef.current;
@@ -78,9 +83,7 @@ function EditableInput({
7883
<button
7984
className="editable-input__label"
8085
onClick={beginEditing}
81-
aria-label={
82-
ariaLabel ?? t('EditableInput.EditValue', { display: displayValue })
83-
}
86+
aria-label={label}
8487
aria-hidden={isEditing}
8588
disabled={disabled}
8689
>
@@ -97,7 +100,7 @@ function EditableInput({
97100
type="text"
98101
{...inputProps}
99102
disabled={!isEditing}
100-
aria-hidden={!isEditing}
103+
aria-label={label}
101104
onBlur={doneEditing}
102105
onChange={updateValue}
103106
onKeyDown={checkForKeyAction}
@@ -115,6 +118,7 @@ EditableInput.defaultProps = {
115118
validate: () => true,
116119
value: '',
117120
disabled: false,
121+
description: undefined,
118122
'aria-label': undefined
119123
};
120124

@@ -127,6 +131,7 @@ EditableInput.propTypes = {
127131
validate: PropTypes.func,
128132
value: PropTypes.string,
129133
disabled: PropTypes.bool,
134+
description: PropTypes.string,
130135
'aria-label': PropTypes.string
131136
};
132137

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)