Skip to content

Commit 9a092c3

Browse files
committed
Fix custom wrapper nodes causing incorrect collapse
1 parent e553171 commit 9a092c3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

demo/src/JsonEditImport.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
*/
44

55
/* Installed package */
6-
export * from 'json-edit-react'
6+
// export * from 'json-edit-react'
77

88
/* Local src */
9-
// export * from './json-edit-react/src'
9+
export * from './json-edit-react/src'
1010

1111
/* Compiled local package */
1212
// export * from './package'

src/CollectionNode.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ export const CollectionNode: React.FC<CollectionNodeProps> = ({
9393
[defaultValue]
9494
)
9595

96+
const {
97+
CustomNode,
98+
customNodeProps,
99+
CustomWrapper,
100+
wrapperProps = {},
101+
hideKey,
102+
showEditTools = true,
103+
showOnEdit,
104+
showOnView,
105+
showCollectionWrapper = true,
106+
} = useMemo(() => getCustomNode(customNodeDefinitions, nodeData), [])
107+
96108
// Early return if this node is filtered out
97109
if (!filterNode('collection', nodeData, searchFilter, searchText) && nodeData.level > 0) {
98110
return null
@@ -274,18 +286,6 @@ export const CollectionNode: React.FC<CollectionNodeProps> = ({
274286
</div>
275287
)
276288

277-
const {
278-
CustomNode,
279-
customNodeProps,
280-
CustomWrapper,
281-
wrapperProps = {},
282-
hideKey,
283-
showEditTools = true,
284-
showOnEdit,
285-
showOnView,
286-
showCollectionWrapper = true,
287-
} = getCustomNode(customNodeDefinitions, nodeData)
288-
289289
// If the collection wrapper (expand icon, brackets, etc) is hidden, there's
290290
// no way to open a collapsed custom node, so this ensures it will stay open.
291291
// It can still be displayed collapsed by handling it internally if this is

0 commit comments

Comments
 (0)