Skip to content

Conversation

@Minamiyama
Copy link
Contributor

@Minamiyama Minamiyama commented Jul 10, 2025

Summary

Implement drag-and-drop reordering of variables in the workflow editor using react-sortablejs. Added draggable handle icon that appears on hover when there are multiple variables. Each variable now has a unique ID to maintain state during reordering.

related #22066

Screenshots

after-.mp4

follow feat(question-classifier): add drag-and-drop sorting for topics list (#22066)

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Implement drag-and-drop reordering of variables in the workflow editor using react-sortablejs. Added draggable handle icon that appears on hover when there are multiple variables. Each variable now has a unique ID to maintain state during reordering.
The property name 'p' was changed to 'v' to better represent its purpose as a variable container. This improves code readability and maintainability.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 🌊 feat:workflow Workflow related stuff. labels Jul 10, 2025
@crazywoola crazywoola requested a review from Copilot July 10, 2025 06:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces drag-and-drop reordering of variables in the code node’s variable list using react-sortablejs.

  • Adds imports for ReactSortable, uuid, and a draggable icon
  • Generates per-item UUIDs and wraps the list in ReactSortable
  • Displays a drag handle on hover when more than one variable is present

Use useMemo for listWithIds to optimize performance by avoiding unnecessary recalculations. Also rename payloadWithIds to listWithIds for better clarity.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 10, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 10, 2025
Ensure unique keys for list items by using item.id when available, falling back to index. This prevents potential React key conflicts during re-renders.
…drag handle position

Remove unnecessary mapping of list items with IDs and use direct variable references. Adjust drag handle position for better visual alignment.
@crazywoola crazywoola merged commit 66cc1b4 into langgenius:main Jul 16, 2025
5 checks passed
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 16, 2025
tutkun pushed a commit to tutkun/dify that referenced this pull request Aug 15, 2025
tutkun pushed a commit to tutkun/dify that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌊 feat:workflow Workflow related stuff. lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants