fix(react): useNodesInitialized true when nodes measured closes #4202
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
## Patch changes
|
## Patch changes
|
||||||
|
|
||||||
- fix batching for `setNodes`, `updateNode`, `updateNodeData` etc.
|
- fix batching for `setNodes`, `updateNode`, `updateNodeData` etc.
|
||||||
|
- fix `useNodesInitialized`
|
||||||
|
|
||||||
## 12.0.0-next.15
|
## 12.0.0-next.15
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useStore } from './useStore';
|
import { useStore } from './useStore';
|
||||||
import type { ReactFlowState } from '../types';
|
import type { ReactFlowState } from '../types';
|
||||||
|
import { nodeHasDimensions } from '@xyflow/system';
|
||||||
|
|
||||||
export type UseNodesInitializedOptions = {
|
export type UseNodesInitializedOptions = {
|
||||||
includeHiddenNodes?: boolean;
|
includeHiddenNodes?: boolean;
|
||||||
@@ -10,9 +11,9 @@ const selector = (options: UseNodesInitializedOptions) => (s: ReactFlowState) =>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [, node] of s.nodeLookup) {
|
for (const [, { hidden, internals }] of s.nodeLookup) {
|
||||||
if (options.includeHiddenNodes || !node.hidden) {
|
if (options.includeHiddenNodes || !hidden) {
|
||||||
if (node.internals.handleBounds === undefined) {
|
if (internals.handleBounds === undefined || !nodeHasDimensions(internals.userNode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user