diff --git a/modules/react-arborist/src/components/provider.tsx b/modules/react-arborist/src/components/provider.tsx index 5047ebb..ea45b0a 100644 --- a/modules/react-arborist/src/components/provider.tsx +++ b/modules/react-arborist/src/components/provider.tsx @@ -57,7 +57,15 @@ export function TreeProvider({ useMemo(() => { updateCount.current += 1; api.update(treeProps); - }, [...Object.values(treeProps), state.nodes.open]); + }, [...Object.values(treeProps)]); + + /* Rebuild visible nodes when open state changes, without clobbering + props set imperatively via api.update(). Bumping updateCount keeps + DataUpdates consumers (e.g. DefaultContainer) in sync. */ + useMemo(() => { + updateCount.current += 1; + api.update(api.props); + }, [state.nodes.open]); /* Expose the tree api */ useImperativeHandle(imperativeHandle, () => api);