fix: customize drag image to only show component icon#5314
Open
OptimumCoder1 wants to merge 1 commit into
Open
fix: customize drag image to only show component icon#5314OptimumCoder1 wants to merge 1 commit into
OptimumCoder1 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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
WorkflowNodesTabsItemdrag-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); |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ran command:
git remote add fork https://github.com/OptimumCoder1/bytechef.gitRan command:
git push -u fork fix/sidebar-drag-image-iconViewed 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
onDragStartinsideWorkflowNodesTabsItem.tsxto build the custom drag image element (nodeContainer) with inline styling. This ensures the browser layout engine calculates the styles synchronously.nodeContainer.offsetWidthwithin the initialization ofdragX(which gets passed tosetDragImage). This ensures the browser computes layout/dimensions prior to taking the drag snapshot.WorkflowNodesTabsItem.test.tsxverifying component rendering, click callback triggers, andonDragStartpayload configuration and drag image setup.Fixes # (No existing upstream issue, submitted as a direct UX enhancement)
Type of change
How Has This Been Tested?
I ran local verification checks in the
client/directory:Unit Testing (Vitest):
Ran unit tests specifically targeting the item component:
Result: All 4 tests passed.
Workspace Verification Checks:
Ran full formatting, linting, typechecking, and test validation:
Result: Completed successfully with no formatting, typescript, or testing errors.
Checklist: