Skip to content

Commit

Permalink
feat(canvas): Hide action buttons during node dragging
Browse files Browse the repository at this point in the history
- Add dragging state check to conditionally render memo node action buttons
- Integrate editor performance context to track dragging node
- Prevent action buttons from appearing while a node is being dragged
  • Loading branch information
CH1111 committed Feb 14, 2025
1 parent 32695b4 commit 2ee7fe1
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { useCanvasData } from '@refly-packages/ai-workspace-common/hooks/canvas/
import { useAddNode } from '@refly-packages/ai-workspace-common/hooks/canvas/use-add-node';
import { genSkillID } from '@refly-packages/utils/id';
import { IContextItem } from '@refly-packages/ai-workspace-common/stores/context-panel';

import { useEditorPerformance } from '@refly-packages/ai-workspace-common/context/editor-performance';
export const MemoNode = ({
data,
selected,
Expand All @@ -58,8 +58,6 @@ export const MemoNode = ({
const language = i18n.languages?.[0];
const { addNode } = useAddNode();

// console.log('memo', id);

const { getNode } = useReactFlow();
const node = getNode(id);
const targetRef = useRef<HTMLDivElement>(null);
Expand All @@ -70,6 +68,8 @@ export const MemoNode = ({
const { operatingNodeId } = useCanvasStoreShallow((state) => ({
operatingNodeId: state.operatingNodeId,
}));
const { draggingNodeId } = useEditorPerformance();
const isDragging = draggingNodeId === id;

const { handleMouseEnter: onHoverStart, handleMouseLeave: onHoverEnd } = useNodeHoverEffect(id);

Expand Down Expand Up @@ -297,7 +297,7 @@ export const MemoNode = ({
{!isPreview && selected && (
<MemoEditor editor={editor} bgColor={bgColor} onChangeBackground={onUpdateBgColor} />
)}
{!isPreview && !hideActions && (
{!isPreview && !hideActions && !isDragging && (
<ActionButtons type="memo" nodeId={id} isNodeHovered={isHovered} />
)}

Expand Down

0 comments on commit 2ee7fe1

Please sign in to comment.