diff --git a/webapp/src/components/kanban/kanban.tsx b/webapp/src/components/kanban/kanban.tsx index eeb99664d..c295ef29c 100644 --- a/webapp/src/components/kanban/kanban.tsx +++ b/webapp/src/components/kanban/kanban.tsx @@ -58,15 +58,13 @@ const Kanban = (props: Props) => { const currentView = useAppSelector(getCurrentView) const cardTemplates: Card[] = useAppSelector(getCurrentBoardTemplates) const {board, activeView, cards, groupByProperty, visibleGroups, hiddenGroups, hiddenCardsCount} = props - const [defaultTemplateID, setDefaultTemplateID] = useState('') + const [defaultTemplateID, setDefaultTemplateID] = useState() useEffect(() => { - if(currentView.fields && currentView.fields.defaultTemplateId) { - cardTemplates.forEach((cardTemplate) => { - if(cardTemplate.id === currentView.fields.defaultTemplateId) { - setDefaultTemplateID(currentView.fields.defaultTemplateId) - } - }) + if(currentView && currentView.fields && currentView.fields.defaultTemplateId) { + if(cardTemplates.find(ct => ct.id === currentView.fields.defaultTemplateId)) { + setDefaultTemplateID(currentView.fields.defaultTemplateId) + } } }, [currentView]) @@ -310,7 +308,7 @@ const Kanban = (props: Props) => {