diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/TextField.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/TextField.tsx index e237205b0f..26ac52da6a 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/TextField.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/TextField.tsx @@ -3,6 +3,7 @@ import React from 'react'; import Heading from './Heading'; interface ITextField { + inputRef?: React.RefObject; title?: string; value?: string; placeholder?: string; @@ -10,15 +11,16 @@ interface ITextField { onChange?: (event: React.ChangeEvent) => void; } -const TextField: React.FC = ({title, value, placeholder, help, onChange, ...props}) => { +const TextField: React.FC = ({inputRef, title, value, placeholder, help, onChange, ...props}) => { return (
{title && {title}} {help} diff --git a/ghost/admin-x-settings/src/components/settings/general/TitleAndDescription.tsx b/ghost/admin-x-settings/src/components/settings/general/TitleAndDescription.tsx index 67388d8f1c..cf8c369de6 100644 --- a/ghost/admin-x-settings/src/components/settings/general/TitleAndDescription.tsx +++ b/ghost/admin-x-settings/src/components/settings/general/TitleAndDescription.tsx @@ -1,5 +1,5 @@ import ButtonGroup from '../../../admin-x-ds/global/ButtonGroup'; -import React, {useState} from 'react'; +import React, {useEffect, useRef, useState} from 'react'; import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; import SettingGroupHeader from '../../../admin-x-ds/settings/SettingGroupHeader'; import SettingGroupInputs from '../../../admin-x-ds/settings/SettingGroupInputs'; @@ -13,6 +13,13 @@ const TitleAndDescription: React.FC = () => { const [isEdited, setIsEdited] = useState(false); const [siteTitle, setSiteTitleValue] = useState(`Dr. Evil's secret volcano lair`); const [siteDescription, setSiteDescriptionValue] = useState(`I'm doing this for fun`); + const siteTitleRef = useRef(null); + + useEffect(() => { + if (isEditMode && siteTitleRef.current) { + siteTitleRef.current.focus(); + } + }, [isEditMode]); const handleEditClick = () => { setIsEditMode(true); @@ -72,6 +79,7 @@ const TitleAndDescription: React.FC = () => {