diff --git a/src/apps/content-editor/src/app/views/ItemEdit/ItemEdit.js b/src/apps/content-editor/src/app/views/ItemEdit/ItemEdit.js index 3f1d407d82..9b1c2ea1f9 100644 --- a/src/apps/content-editor/src/app/views/ItemEdit/ItemEdit.js +++ b/src/apps/content-editor/src/app/views/ItemEdit/ItemEdit.js @@ -139,20 +139,22 @@ export default function ItemEdit() { } if (itemResponse?.data?.meta?.langID) { - // select lang based on content lang - dispatch( - selectLang( - languages.find((lang) => lang.ID === itemResponse.data.meta.langID) - .code - ) - ); + const selectedLang = languages.find( + (lang) => lang.ID === itemResponse.data.meta.langID + )?.code; - // once we selectLang we can fetchFields - // which triggers middleware which depends on lang - await Promise.all([ - dispatch(fetchFields(modelZUID)), - dispatch(fetchItemPublishing(modelZUID, itemZUID)), - ]); + // Make sure that lang code exists + if (selectedLang) { + // select lang based on content lang + dispatch(selectLang(selectedLang)); + + // once we selectLang we can fetchFields + // which triggers middleware which depends on lang + await Promise.all([ + dispatch(fetchFields(modelZUID)), + dispatch(fetchItemPublishing(modelZUID, itemZUID)), + ]); + } } } catch (err) { console.error("ItemEdit:load:error", err);