diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vue index 56d1f067..f7d8ac14 100644 --- a/src/components/LinkItems/Section.vue +++ b/src/components/LinkItems/Section.vue @@ -244,6 +244,10 @@ export default { }, /* Navigate to the section's single-section view page */ navigateToSection() { + if (!this.title) { + ErrorHandler('Cannot open section without a valid name'); + return; + } const parse = (section) => section.replace(' ', '-').toLowerCase().trim(); const sectionIdentifier = parse(this.title); router.push({ path: `/home/${sectionIdentifier}` }); diff --git a/src/utils/SectionHelpers.js b/src/utils/SectionHelpers.js index 28082bfb..21f392d8 100644 --- a/src/utils/SectionHelpers.js +++ b/src/utils/SectionHelpers.js @@ -7,7 +7,8 @@ export const shouldBeVisible = (routeName) => !hideFurnitureOn.includes(routeNam /* Based on section title, item name and index, return a string value for ID */ const makeItemId = (sectionStr, itemStr, index) => { - const charSum = sectionStr.split('').map((a) => a.charCodeAt(0)).reduce((x, y) => x + y); + const sectionTitle = sectionStr || `unlabeledSec_${Math.random()}`; + const charSum = sectionTitle.split('').map((a) => a.charCodeAt(0)).reduce((x, y) => x + y); const newItemStr = itemStr || `unknown_${Math.random()}`; const itemTitleStr = newItemStr.replace(/\s+/g, '-').replace(/[^a-zA-Z ]/g, '').toLowerCase(); return `${index}_${charSum}_${itemTitleStr}`; diff --git a/src/views/Home.vue b/src/views/Home.vue index e7f097db..d42097ba 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -149,7 +149,7 @@ export default { let sectionToReturn; const parse = (section) => section.replaceAll(' ', '-').toLowerCase().trim(); allSections.forEach((section) => { - if (parse(sectionTitle) === parse(section.name)) { + if (parse(sectionTitle) === parse(section.name || '')) { sectionToReturn = [section]; } });