mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-07-10 03:36:18 -04:00
Make enter submit title field instead of adding newlines
This commit is contained in:
parent
5892f2e7ba
commit
789e15c3ab
1 changed files with 2 additions and 6 deletions
|
@ -9,12 +9,7 @@ import {selectStudioTitle, selectIsFetchingInfo} from '../../redux/studio';
|
||||||
import {selectCanEditInfo} from '../../redux/studio-permissions';
|
import {selectCanEditInfo} from '../../redux/studio-permissions';
|
||||||
import {Errors, mutateStudioTitle, selectIsMutatingTitle, selectTitleMutationError} from '../../redux/studio-mutations';
|
import {Errors, mutateStudioTitle, selectIsMutatingTitle, selectTitleMutationError} from '../../redux/studio-mutations';
|
||||||
import ValidationMessage from '../../components/forms/validation-message.jsx';
|
import ValidationMessage from '../../components/forms/validation-message.jsx';
|
||||||
/*
|
|
||||||
TODO
|
|
||||||
- no newlines in studio title
|
|
||||||
- Correct display in read-only mode
|
|
||||||
- validation message
|
|
||||||
*/
|
|
||||||
const errorToMessageId = error => {
|
const errorToMessageId = error => {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case Errors.INAPPROPRIATE: return 'studio.updateErrors.inappropriate';
|
case Errors.INAPPROPRIATE: return 'studio.updateErrors.inappropriate';
|
||||||
|
@ -38,6 +33,7 @@ const StudioTitle = ({
|
||||||
className={fieldClassName}
|
className={fieldClassName}
|
||||||
disabled={isMutating || !canEditInfo || isFetching}
|
disabled={isMutating || !canEditInfo || isFetching}
|
||||||
defaultValue={title}
|
defaultValue={title}
|
||||||
|
onKeyDown={e => e.key === 'Enter' && e.target.blur()}
|
||||||
onBlur={e => e.target.value !== title &&
|
onBlur={e => e.target.value !== title &&
|
||||||
handleUpdate(e.target.value)}
|
handleUpdate(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue