Skip to content

fix: customize drag image to only show component icon#5314

Open
OptimumCoder1 wants to merge 1 commit into
bytechefhq:masterfrom
OptimumCoder1:fix/sidebar-drag-image-icon
Open

fix: customize drag image to only show component icon#5314
OptimumCoder1 wants to merge 1 commit into
bytechefhq:masterfrom
OptimumCoder1:fix/sidebar-drag-image-icon

Conversation

@OptimumCoder1

Copy link
Copy Markdown

Ran command: git remote add fork https://github.com/OptimumCoder1/bytechef.git
Ran command: git push -u fork fix/sidebar-drag-image-icon
Viewed WorkflowNodesTabsItem.test.tsx:11-48

Here is the filled-out Pull Request template for your PR on GitHub. You can copy and paste this directly:


Description

When dragging a component card from the node sidebar in the workflow editor, the browser dragged the entire card (including the title and description text). This change modifies the drag image to only display the component's icon, while keeping the entire card surface draggable to initiate the drag.

Technical Solution

  • Updated onDragStart inside WorkflowNodesTabsItem.tsx to build the custom drag image element (nodeContainer) with inline styling. This ensures the browser layout engine calculates the styles synchronously.
  • Forced a browser layout reflow by checking nodeContainer.offsetWidth within the initialization of dragX (which gets passed to setDragImage). This ensures the browser computes layout/dimensions prior to taking the drag snapshot.
  • Added unit tests in WorkflowNodesTabsItem.test.tsx verifying component rendering, click callback triggers, and onDragStart payload configuration and drag image setup.

Fixes # (No existing upstream issue, submitted as a direct UX enhancement)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I ran local verification checks in the client/ directory:

  1. Unit Testing (Vitest):
    Ran unit tests specifically targeting the item component:

    npx vitest run src/pages/platform/workflow-editor/components/workflow-nodes-tabs/WorkflowNodesTabsItem.test.tsx

    Result: All 4 tests passed.

  2. Workspace Verification Checks:
    Ran full formatting, linting, typechecking, and test validation:

    npm run check

    Result: Completed successfully with no formatting, typescript, or testing errors.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copilot AI review requested due to automatic review settings July 1, 2026 11:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the workflow editor sidebar drag UX by customizing the browser drag preview to show only the component icon (instead of the full card), while keeping the full card draggable.

Changes:

  • Updated WorkflowNodesTabsItem drag-start logic to build a dedicated offscreen drag-image element containing only the icon.
  • Applied inline styles to the drag-image container and icon clone to control sizing/layout during the drag snapshot.
  • Added Vitest coverage for rendering, click handling, and drag-start data/drag-image setup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
client/src/pages/platform/workflow-editor/components/workflow-nodes-tabs/WorkflowNodesTabsItem.tsx Builds and applies a custom drag image (icon-only) during node card dragging.
client/src/pages/platform/workflow-editor/components/workflow-nodes-tabs/WorkflowNodesTabsItem.test.tsx Adds unit tests for rendering/click behavior and drag-start configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +80 to +83
const dragX = nodeContainer.offsetWidth > 0 ? 28 : 28;
const dragY = 28;

event.dataTransfer.setDragImage(nodeContainer, dragX, dragY);
Comment on lines +1 to +6
import {ComponentDefinitionBasic} from '@/shared/middleware/platform/configuration';
import {fireEvent, render, screen} from '@/shared/util/test-utils';
import {expect, it, vi} from 'vitest';

import WorkflowNodesTabsItem from './WorkflowNodesTabsItem';


expect(setData).toHaveBeenCalledWith(formatString, expectedNodeName);
expect(dataTransfer.effectAllowed).toBe('move');
expect(setDragImage).toHaveBeenCalledTimes(1);
@ivicac ivicac requested a review from kresimir-coko July 1, 2026 19:32
@kresimir-coko

Copy link
Copy Markdown
Collaborator

@OptimumCoder1 Can you give me a quick video of this please, I thought we already had this implemented, see video:

Screen.Recording.2026-07-02.at.20.25.58.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants