diff --git a/web/src/beta/features/Editor/Publish/PublishToolsPanel/hooks.ts b/web/src/beta/features/Editor/Publish/PublishToolsPanel/hooks.ts index fd2aa554dc..fd75d2b592 100644 --- a/web/src/beta/features/Editor/Publish/PublishToolsPanel/hooks.ts +++ b/web/src/beta/features/Editor/Publish/PublishToolsPanel/hooks.ts @@ -72,10 +72,7 @@ export default ({ const generateAlias = useCallback(() => generateRandomString(10), []); const [validAlias, setValidAlias] = useState(false); - const alias = useMemo( - () => project?.alias ?? generateAlias(), - [project?.alias, generateAlias] - ); + const [alias, setAlias] = useState(project?.alias ?? generateAlias()); const [ checkProjectAlias, @@ -110,6 +107,17 @@ export default ({ [project?.alias, checkProjectAlias] ); + useEffect(() => { + if (modalOpen) { + if (!alias) { + const generatedAlias = generateAlias(); + setAlias(generatedAlias); + } + + handleProjectAliasCheck(alias); + } + }, [modalOpen, alias, generateAlias, handleProjectAliasCheck]); + useEffect(() => { setValidAlias( !validatingAlias &&