From 09e253b1c67769d3543f390d3a5d7713ee7268bf Mon Sep 17 00:00:00 2001 From: Flaminia Cavallo Date: Tue, 2 Jul 2024 14:50:49 +0200 Subject: [PATCH] fix: make sure rendering tabs does not crash if display options are in the wrong format --- src/data-workspace/section-form/section-form.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/data-workspace/section-form/section-form.js b/src/data-workspace/section-form/section-form.js index 4250a3f14..2cb3d65ea 100644 --- a/src/data-workspace/section-form/section-form.js +++ b/src/data-workspace/section-form/section-form.js @@ -6,6 +6,15 @@ import { useSectionFilter } from '../../shared/index.js' import { SectionFormSection } from './section.js' import styles from './section.module.css' +const parseDisplayOptions = (displayOptionString) => { + try { + return displayOptionString && JSON.parse(displayOptionString) + } catch (e) { + console.error(e) + return undefined + } +} + export const SectionForm = ({ dataSet, globalFilterText }) => { const [sectionId] = useSectionFilter() const filteredSections = sectionId @@ -13,8 +22,7 @@ export const SectionForm = ({ dataSet, globalFilterText }) => { : dataSet.sections const { displayOptions: displayOptionString } = dataSet - const displayOptions = - displayOptionString && JSON.parse(displayOptionString) + const displayOptions = parseDisplayOptions(displayOptionString) if (dataSet.renderAsTabs) { return (