Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions client/modules/IDE/components/EditableInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function EditableInput({
inputProps,
onChange,
disabled,
description,
'aria-label': ariaLabel
}) {
const [isEditing, setIsEditing] = React.useState(false);
Expand All @@ -26,6 +27,14 @@ function EditableInput({
}`;
const inputRef = React.useRef();
const { t } = useTranslation();
const inputLabel =
description ??
ariaLabel ??
t('EditableInput.EditValue', { display: displayValue });
const buttonLabel =
ariaLabel ??
description ??
t('EditableInput.EditValue', { display: displayValue });
React.useEffect(() => {
if (isEditing) {
const inputElement = inputRef.current;
Expand Down Expand Up @@ -78,9 +87,7 @@ function EditableInput({
<button
className="editable-input__label"
onClick={beginEditing}
aria-label={
ariaLabel ?? t('EditableInput.EditValue', { display: displayValue })
}
aria-label={buttonLabel}
aria-hidden={isEditing}
disabled={disabled}
>
Expand All @@ -98,6 +105,7 @@ function EditableInput({
{...inputProps}
disabled={!isEditing}
aria-hidden={!isEditing}
aria-label={inputLabel}
onBlur={doneEditing}
onChange={updateValue}
onKeyDown={checkForKeyAction}
Expand All @@ -115,6 +123,7 @@ EditableInput.defaultProps = {
validate: () => true,
value: '',
disabled: false,
description: undefined,
'aria-label': undefined
};

Expand All @@ -127,6 +136,7 @@ EditableInput.propTypes = {
validate: PropTypes.func,
value: PropTypes.string,
disabled: PropTypes.bool,
description: PropTypes.string,
'aria-label': PropTypes.string
};

Expand Down
4 changes: 2 additions & 2 deletions client/modules/IDE/components/Header/ProjectName.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export default function ProjectName() {
<EditableInput
value={projectName}
disabled={!canEditProjectName}
description={t('Toolbar.NewSketchNameARIA')}
aria-label={t('Toolbar.EditSketchARIA')}
inputProps={{
maxLength: 128,
'aria-label': t('Toolbar.NewSketchNameARIA')
maxLength: 128
}}
validate={(text) => text.trim().length > 0}
onChange={changeSketchName}
Expand Down
2 changes: 2 additions & 0 deletions client/modules/User/components/CollectionMetadata.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function CollectionMetadata({ collectionId }) {
<EditableInput
value={name}
onChange={handleEditCollectionName}
aria-label={t('Collection.NameARIA')}
validate={(value) => value !== ''}
/>
) : (
Expand All @@ -76,6 +77,7 @@ function CollectionMetadata({ collectionId }) {
InputComponent="textarea"
value={description}
onChange={handleEditCollectionDescription}
aria-label={t('Collection.DescriptionARIA')}
emptyPlaceholder={t('Collection.DescriptionPlaceholder')}
/>
) : (
Expand Down
3 changes: 3 additions & 0 deletions translations/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@
},
"Collection": {
"Title": "p5.js Web Editor | My collections",
"NameARIA": "Collection Name",
"DescriptionARIA": "Collection Description",
"AnothersTitle": "p5.js Web Editor | {{anotheruser}}'s collections",
"Share": "Share",
"URLLink": "Link to Collection",
Expand Down Expand Up @@ -566,6 +568,7 @@
"HeaderCreatedAt": "Date Created",
"HeaderCreatedAt_mobile": "Created",
"HeaderUpdatedAt": "Date Updated",
"EditCollectionARIA": "Edit Collection name",
"HeaderUpdatedAt_mobile": "Updated",
"HeaderNumItems": "# sketches",
"HeaderNumItems_mobile": "# sketches",
Expand Down
Loading