diff --git a/wegas-app/src/main/node/wegas-react/src/Editor/Components/Languages/LanguageEditor.tsx b/wegas-app/src/main/node/wegas-react/src/Editor/Components/Languages/LanguageEditor.tsx index e3658a977b..398fd42284 100644 --- a/wegas-app/src/main/node/wegas-react/src/Editor/Components/Languages/LanguageEditor.tsx +++ b/wegas-app/src/main/node/wegas-react/src/Editor/Components/Languages/LanguageEditor.tsx @@ -49,7 +49,6 @@ createLanguageSchema.properties!['active'].view!.type = 'hidden'; const editLanguageSchema = cloneDeep(languageSchema); editLanguageSchema.properties!['visibility'].view!.type = 'hidden'; -editLanguageSchema.properties!['visibility'].view!.type = 'hidden'; ( editLanguageSchema.properties!['code'].view! as { readOnly: boolean } ).readOnly = true; @@ -128,19 +127,24 @@ export default function LanguageEditor() { const schema = selectedLanguage.id == null ? createLanguageSchema : editLanguageSchema; - if ( - Array.isArray(translatableLanguages) && - schema.properties != null && - schema.properties['code'] != null && - schema.properties['code']['view'] != null - ) { - schema.properties.code.view.type = 'select'; - (schema.properties.code as ISelectProps).view.choices = - translatableLanguages.filter( - code => !languages.map(lang => lang.code).includes(code), - ); - (schema.properties.code as ISelectProps).view.allowAnyValue = true; - } + React.useEffect(() => { + if ( + Array.isArray(translatableLanguages) && + translatableLanguages.length > 0 && + createLanguageSchema.properties != null && + createLanguageSchema.properties['code'] != null && + createLanguageSchema.properties['code']['view'] != null + ) { + createLanguageSchema.properties.code.view.type = 'select'; + (createLanguageSchema.properties.code as ISelectProps).view.choices = + translatableLanguages.filter( + code => !languages.map(lang => lang.code).includes(code), + ); + ( + createLanguageSchema.properties.code as ISelectProps + ).view.allowAnyValue = true; + } + }, [translatableLanguages, languages, createLanguageSchema]); return (