fix(minimap): return usernode

This commit is contained in:
moklick
2025-04-02 13:53:32 +02:00
parent 5c66916370
commit 0f293eebae
@@ -6,7 +6,7 @@ import { shallow } from 'zustand/shallow';
import { useStore } from '../../hooks/useStore'; import { useStore } from '../../hooks/useStore';
import { MiniMapNode } from './MiniMapNode'; import { MiniMapNode } from './MiniMapNode';
import type { ReactFlowState, Node, InternalNode } from '../../types'; import type { ReactFlowState, Node } from '../../types';
import type { MiniMapNodes as MiniMapNodesProps, GetMiniMapNodeAttribute, MiniMapNodeProps } from './types'; import type { MiniMapNodes as MiniMapNodesProps, GetMiniMapNodeAttribute, MiniMapNodeProps } from './types';
declare const window: any; declare const window: any;
@@ -42,7 +42,7 @@ function MiniMapNodes<NodeType extends Node>({
* The split of responsibilities between MiniMapNodes and * The split of responsibilities between MiniMapNodes and
* NodeComponentWrapper may appear weird. However, its designed to * NodeComponentWrapper may appear weird. However, its designed to
* minimize the cost of updates when individual nodes change. * minimize the cost of updates when individual nodes change.
* *
* For more details, see a similar commit in `NodeRenderer/index.tsx`. * For more details, see a similar commit in `NodeRenderer/index.tsx`.
*/ */
<NodeComponentWrapper<NodeType> <NodeComponentWrapper<NodeType>
@@ -84,8 +84,9 @@ function NodeComponentWrapperInner<NodeType extends Node>({
shapeRendering: string; shapeRendering: string;
}) { }) {
const { node, x, y, width, height } = useStore((s) => { const { node, x, y, width, height } = useStore((s) => {
const node = s.nodeLookup.get(id) as InternalNode<NodeType>; const { internals } = s.nodeLookup.get(id)!;
const { x, y } = node.internals.positionAbsolute; const node = internals.userNode as NodeType;
const { x, y } = internals.positionAbsolute;
const { width, height } = getNodeDimensions(node); const { width, height } = getNodeDimensions(node);
return { return {