|
@@ -6,6 +6,7 @@ import {
|
|
|
getUserFacingMessage,
|
|
getUserFacingMessage,
|
|
|
postJSON,
|
|
postJSON,
|
|
|
} from '../../../../infrastructure/fetch-json'
|
|
} from '../../../../infrastructure/fetch-json'
|
|
|
|
|
+import { useRefWithAutoFocus } from '../../../../shared/hooks/use-ref-with-auto-focus'
|
|
|
|
|
|
|
|
type NewProjectData = {
|
|
type NewProjectData = {
|
|
|
project_id: string
|
|
project_id: string
|
|
@@ -25,6 +26,7 @@ type Props = {
|
|
|
|
|
|
|
|
function ModalContentNewProjectForm({ onCancel, template = 'none' }: Props) {
|
|
function ModalContentNewProjectForm({ onCancel, template = 'none' }: Props) {
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
|
|
+ const { autoFocusedRef } = useRefWithAutoFocus<HTMLInputElement>()
|
|
|
const [projectName, setProjectName] = useState('')
|
|
const [projectName, setProjectName] = useState('')
|
|
|
const { isLoading, isError, error, runAsync } = useAsync<NewProjectData>()
|
|
const { isLoading, isError, error, runAsync } = useAsync<NewProjectData>()
|
|
|
|
|
|
|
@@ -62,8 +64,10 @@ function ModalContentNewProjectForm({ onCancel, template = 'none' }: Props) {
|
|
|
{isError && (
|
|
{isError && (
|
|
|
<Alert bsStyle="danger">{getUserFacingMessage(error)}</Alert>
|
|
<Alert bsStyle="danger">{getUserFacingMessage(error)}</Alert>
|
|
|
)}
|
|
)}
|
|
|
- <FormControl
|
|
|
|
|
|
|
+ <input
|
|
|
type="text"
|
|
type="text"
|
|
|
|
|
+ className="form-control"
|
|
|
|
|
+ ref={autoFocusedRef}
|
|
|
placeholder={t('project_name')}
|
|
placeholder={t('project_name')}
|
|
|
onChange={handleChangeName}
|
|
onChange={handleChangeName}
|
|
|
value={projectName}
|
|
value={projectName}
|