Skip to content

Commit

Permalink
fix(Block): fix block's selection
Browse files Browse the repository at this point in the history
  • Loading branch information
draedful committed Oct 8, 2024
1 parent c2e4cd2 commit 5438d69
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/react-component/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TBlock } from "../components/canvas/blocks/Block";
import { Graph } from "../graph";
import "./Block.css";
import { setCssProps } from "../utils/functions/cssProp";
import { useBlockViewState } from "./hooks/useBlockState";
import { useBlockState, useBlockViewState } from "./hooks/useBlockState";

export const GraphBlock = <T extends TBlock>({
graph,
Expand All @@ -20,6 +20,7 @@ export const GraphBlock = <T extends TBlock>({
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const viewState = useBlockViewState(graph, block);
const state = useBlockState(graph, block);

useLayoutEffect(() => {
setCssProps(containerRef.current, {
Expand All @@ -44,7 +45,7 @@ export const GraphBlock = <T extends TBlock>({

return (
<div className={`graph-block-container ${containerClassName}`} ref={containerRef}>
<div className={`graph-block-wrapper ${className} ${block.selected ? "selected" : ""}`}>{children}</div>
<div className={`graph-block-wrapper ${className} ${state.selected ? "selected" : ""}`}>{children}</div>
</div>
);
};

0 comments on commit 5438d69

Please sign in to comment.