Skip to content

Commit

Permalink
fix: make sure rendering tabs does not crash if display options are i…
Browse files Browse the repository at this point in the history
…n the wrong format
  • Loading branch information
Flaminia Cavallo authored and Flaminia Cavallo committed Jul 2, 2024
1 parent a3f389b commit 09e253b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/data-workspace/section-form/section-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ 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
? dataSet.sections.filter((s) => s.id === sectionId)
: dataSet.sections

const { displayOptions: displayOptionString } = dataSet
const displayOptions =
displayOptionString && JSON.parse(displayOptionString)
const displayOptions = parseDisplayOptions(displayOptionString)

if (dataSet.renderAsTabs) {
return (
Expand Down

0 comments on commit 09e253b

Please sign in to comment.