Skip to content

Conversation

@Minamiyama
Copy link
Contributor

@Minamiyama Minamiyama commented Jul 9, 2025

Summary

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

  • Implement topic sorting functionality using react-sortablejs
  • Add draggable handle and visual feedback during sorting
  • Update node internals after sorting to ensure proper rendering

fixes #22065

Screenshots

after-.mp4

Update

editor header also can be draggable

after-header-draggable.mp4

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 topic sorting functionality using react-sortablejs
- Add draggable handle and visual feedback during sorting
- Update node internals after sorting to ensure proper rendering
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. ☕️ typescript 💪 enhancement New feature or request labels Jul 9, 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 9, 2025
@crazywoola crazywoola requested review from Copilot, iamjoel and zxhlyh July 9, 2025 05:45
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

This PR adds drag-and-drop sorting for the question-classifier topics list using ReactSortable and ensures the node is re-rendered after reorder.

  • Introduce handleSortTopic in use-config.ts to update the class list and call updateNodeInternals.
  • Pass handleSortTopic through panel.tsx into ClassList.
  • Replace static list rendering in class-list.tsx with ReactSortable and a draggable handle.

Reviewed Changes

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

File Description
web/app/components/workflow/nodes/question-classifier/use-config.ts Added handleSortTopic callback and useUpdateNodeInternals import to support reordering
web/app/components/workflow/nodes/question-classifier/panel.tsx Passed new handleSortTopic prop to the topics list component
web/app/components/workflow/nodes/question-classifier/components/class-list.tsx Swapped wrapper <div> for ReactSortable, added draggable handle, and related state imports
Comments suppressed due to low confidence (1)

web/app/components/workflow/nodes/question-classifier/use-config.ts:171

  • There are no tests covering the new handleSortTopic logic and re-render via updateNodeInternals. Consider adding unit or integration tests to verify that sorting updates the inputs and node internals correctly.
  const handleSortTopic = useCallback((newTopics: (Topic & { id: string })[]) => {

@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 9, 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 9, 2025
Minamiyama and others added 2 commits July 9, 2025 18:46
- Add className and headerClassName props to ClassItem for better styling control
- Conditionally render drag handle based on readonly state and topic count
- Update drag handle styling to only show when hovered and draggable
Copy link
Member

@crazywoola crazywoola left a comment

Choose a reason for hiding this comment

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

I have restored the UI with removing the extra padding and the handler.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 10, 2025
@crazywoola crazywoola merged commit a9cc19f into langgenius:main Jul 10, 2025
5 checks passed
Scorpion1221 added a commit to yybht155/dify that referenced this pull request Jul 16, 2025
* commit '390e4cc0bf203a979e13694ed99ec9fda6b42cc8': (143 commits)
  chore(version): bump to 1.6.0 (langgenius#22136)
  chore: fix schema editor can not hover item (langgenius#22155)
  fix: add the default value to the dark icon (langgenius#22149)
  feat: support ping method for MCP server (langgenius#22144)
  fix: mcp server card button display (langgenius#22141)
  feat: add support for dark icons in provider and tool entities (langgenius#22081)
  update worklow events logs. (langgenius#19871)
  chore: translate i18n files (langgenius#22132)
  feat: the frontend part of mcp (langgenius#22131)
  feat: add MCP support (langgenius#20716)
  Fix: Resolve issue with json_output (langgenius#22053)
  Chore: rm useless import and vars (langgenius#22108)
  feat: add redis fallback mechanism langgenius#21043 (langgenius#21044)
  optimize: batch embedding and qdrant write_consistency_factor parameter (langgenius#21776)
  chore: Update theme vars (langgenius#22113)
  feat(question-classifier): add drag-and-drop sorting for topics list (langgenius#22066)
  test: add comprehensive unit tests for encrypter module (langgenius#22102)
  fix: allow update plugin install settings (langgenius#22111)
  fix(Drawer): add overflow hidden to ensure copy button is always clickable (langgenius#21992) (langgenius#22103)
  Update clean_document_task.py (langgenius#22090)
  ...

# Conflicts:
#	api/core/helper/code_executor/template_transformer.py
#	api/pyproject.toml
#	api/uv.lock
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

💪 enhancement New feature or request 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.

Feature Request: Enable Drag-and-Drop Sorting for Question Classifier node

2 participants