Skip to content

Commit 42b934d

Browse files
committed
fix: rjsf page break on hidden fail
1 parent 81c5a7f commit 42b934d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Common/RJSF/templates/ObjectFieldTemplate.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ const Field = ({
5353
if (!hiddenSchemaProp) {
5454
return true
5555
}
56-
const value = JSONPath({ path: hiddenSchemaProp.match, json: formData })?.[0]
57-
const isHidden = value === undefined || hiddenSchemaProp.condition === value
58-
// NOTE: if should be hidden then filter it out i.e return false
59-
return !isHidden
56+
try {
57+
const value = JSONPath({ path: hiddenSchemaProp.match, json: formData })?.[0]
58+
const isHidden = value === undefined || hiddenSchemaProp.condition === value
59+
return !isHidden
60+
} catch {
61+
return true
62+
}
6063
})
6164
// NOTE: we probably should use uiSchema instead?
6265
.sort((prop) => (schema.properties?.[prop.name]?.type === 'boolean' ? -1 : 1))

src/Shared/validations.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ export const validateUniqueKeys = (keys: string[]) => {
251251

252252
export const validateJSON = (json: string): ValidationResponseType => {
253253
try {
254-
JSON.parse(json)
254+
if (json) {
255+
JSON.parse(json)
256+
}
255257
return {
256258
isValid: true,
257259
}

0 commit comments

Comments
 (0)