Skip to content

Commit 209454e

Browse files
committed
fix: hidden prop matching pagebreak
1 parent e26afb1 commit 209454e

File tree

5 files changed

+87
-2
lines changed

5 files changed

+87
-2
lines changed

package-lock.json

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"dependencies": {
9393
"ansi_up": "^5.2.1",
9494
"fast-json-patch": "^3.1.1",
95+
"jsonpath-plus": "^9.0.0",
9596
"react-monaco-editor": "^0.54.0",
9697
"sass": "^1.69.7",
9798
"tslib": "^2.4.1"

src/Common/Helper.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import React, { SyntheticEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
18+
import { JSONPath, JSONPathOptions } from 'jsonpath-plus'
1819
import { components } from 'react-select'
1920
import * as Sentry from '@sentry/browser'
2021
import moment from 'moment'
@@ -725,6 +726,12 @@ export const powerSetOfSubstringsFromStart = (strings: string[], regex: RegExp)
725726
return _keys
726727
})
727728

729+
export const flatMapOfJSONPaths = (
730+
paths: string[],
731+
json: object,
732+
resultType: JSONPathOptions['resultType'] = 'path',
733+
): string[] => paths.flatMap((path) => JSONPath({ path, json, resultType }))
734+
728735
/**
729736
* Returns a debounced variant of the function
730737
*/

src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const AddButton = ({
4646
title="Add"
4747
>
4848
<PlusIcon className="icon-dim-16 fcb-5" />
49-
<span className="cb-5 fs-13 lh-24 dc__truncate">{content}</span>
49+
<span className="cb-5 fs-13 lh-34 dc__truncate">{content}</span>
5050
</button>
5151
</Tippy>
5252
</div>

src/Common/RJSF/templates/ObjectFieldTemplate.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ const Field = ({
5454
return true
5555
}
5656
const isHidden =
57-
hiddenSchemaProp.condition === JSONPath({ path: hiddenSchemaProp.match, json: formData })[0]
57+
// NOTE: if json is null, then JSONPath will return undefined; hence the ?
58+
hiddenSchemaProp.condition === JSONPath({ path: hiddenSchemaProp.match, json: formData })?.[0]
5859
// NOTE: if should be hidden then filter it out i.e return false
5960
return !isHidden
6061
})
62+
// NOTE: we probably should use uiSchema instead?
6163
.sort((prop) => (schema.properties?.[prop.name]?.type === 'boolean' ? -1 : 1))
6264
.map((prop) => prop.content)
6365

0 commit comments

Comments
 (0)