diff --git a/apps/builder/src/features/editor/components/TypebotHeader/EditableTypebotName.tsx b/apps/builder/src/features/editor/components/TypebotHeader/EditableTypebotName.tsx index 25e937daac..b1d1965937 100644 --- a/apps/builder/src/features/editor/components/TypebotHeader/EditableTypebotName.tsx +++ b/apps/builder/src/features/editor/components/TypebotHeader/EditableTypebotName.tsx @@ -4,23 +4,31 @@ import { EditableInput, Tooltip, } from '@chakra-ui/react' -import React, { useEffect, useState } from 'react' +import React, { useState } from 'react' type EditableProps = { - name: string + defaultName: string onNewName: (newName: string) => void } -export const EditableTypebotName = ({ name, onNewName }: EditableProps) => { - const [localName, setLocalName] = useState(name) +export const EditableTypebotName = ({ + defaultName, + onNewName, +}: EditableProps) => { + const [currentName, setCurrentName] = useState(defaultName) - useEffect(() => { - if (name !== localName) setLocalName(name) - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [name]) + const submitNewName = (newName: string) => { + if (newName === '') return setCurrentName(defaultName) + if (newName === defaultName) return + onNewName(newName) + } return ( - + { display="flex" alignItems="center" fontSize="14px" + minW="30px" + minH="20px" + bgColor={currentName === '' ? 'gray.100' : 'white'} /> diff --git a/apps/builder/src/features/editor/components/TypebotHeader/TypebotHeader.tsx b/apps/builder/src/features/editor/components/TypebotHeader/TypebotHeader.tsx index 8e0475262b..b2ce02aaae 100644 --- a/apps/builder/src/features/editor/components/TypebotHeader/TypebotHeader.tsx +++ b/apps/builder/src/features/editor/components/TypebotHeader/TypebotHeader.tsx @@ -153,7 +153,8 @@ export const TypebotHeader = () => { )} {typebot?.name && ( )}