Skip to content

Commit

Permalink
fix: position
Browse files Browse the repository at this point in the history
  • Loading branch information
Vtec234 committed May 16, 2024
1 parent fcdc866 commit ca66ebb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions widget/src/infoGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { graphviz } from 'd3-graphviz';

interface Node {
id : string;
pos : DocumentPosition
html : Html;
}

Expand All @@ -19,8 +18,7 @@ interface Graph {

export default ({nodes, dot, pos, defaultHtml} : Graph) => {
const graphRef = useRef<HTMLDivElement>(null);
const [infoState, setInfoState] =
useState<{ pos : DocumentPosition, html : Html}>({pos : pos, html : defaultHtml});
const [infoState, setInfoState] = useState<Html>(defaultHtml);

useEffect(() => {
const nodeMap = new Map(nodes.map(node => [node.id, node]))
Expand Down Expand Up @@ -57,13 +55,13 @@ export default ({nodes, dot, pos, defaultHtml} : Graph) => {
const node = nodeMap.get(nodeId);

if (node) {
setInfoState({ pos : node.pos, html : node.html });
setInfoState(node.html);
};
});
});
d3.select(graphRef.current)
.on("click", () => {
setInfoState({ pos : pos, html : defaultHtml });
setInfoState(defaultHtml);
});

});
Expand All @@ -72,7 +70,7 @@ export default ({nodes, dot, pos, defaultHtml} : Graph) => {
return (
<div>
<div ref={graphRef} />
<HtmlDisplay pos={infoState.pos} html={infoState.html} />
<HtmlDisplay pos={pos} html={infoState} />
</div>
);
}

0 comments on commit ca66ebb

Please sign in to comment.