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 c00171e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 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,26 @@ 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(this.props.model['displayOptions'])
)
} 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 c00171e

Please sign in to comment.