File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/Title Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 11import React , { useState } from 'react' ;
22import { observer } from 'mobx-react-lite' ;
33import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name' ;
4+ import { ESC , ENTER } from '@codesandbox/common/lib/utils/keycodes' ;
45import { useSignals , useStore } from 'app/store' ;
56import { WorkspaceInputContainer } from '../../elements' ;
67import { EditPen } from '../elements' ;
@@ -32,7 +33,7 @@ export const Title = observer<ITitleProps>(({ editable }) => {
3233 el . focus ( ) ;
3334 }
3435 } }
35- value = { title || getSandboxName ( currentSandbox ) }
36+ value = { title }
3637 onChange = { event => {
3738 valueChanged ( {
3839 field : 'title' ,
@@ -44,17 +45,29 @@ export const Title = observer<ITitleProps>(({ editable }) => {
4445 setEditing ( false ) ;
4546 } }
4647 onKeyUp = { event => {
47- if ( event . keyCode === 13 ) {
48+ if ( event . keyCode === ENTER ) {
4849 sandboxInfoUpdated ( ) ;
4950 setEditing ( false ) ;
51+ } else if ( event . keyCode === ESC ) {
52+ setEditing ( false ) ;
5053 }
5154 } }
5255 />
5356 </ WorkspaceInputContainer >
5457 ) : (
5558 < SandboxTitle >
5659 { getSandboxName ( currentSandbox ) }
57- { editable && < EditPen onClick = { ( ) => setEditing ( true ) } /> }
60+ { editable && (
61+ < EditPen
62+ onClick = { ( ) => {
63+ valueChanged ( {
64+ field : 'title' ,
65+ value : getSandboxName ( currentSandbox ) ,
66+ } ) ;
67+ setEditing ( true ) ;
68+ } }
69+ />
70+ ) }
5871 </ SandboxTitle >
5972 ) ;
6073} ) ;
You can’t perform that action at this time.
0 commit comments