mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-22 05:19:03 +00:00
fix: address review feedback on TabSubgraphInputs drag-and-drop
- Fix stale index closures after reorder: watch promotionEntries and re-register drag handlers via nextTick so consecutive drags pass correct fromIndex/toIndex to movePromotion - Replace `as number` type assertion with typeof guard per project guidelines - Tighten cleanup test assertion to toHaveBeenCalledTimes(2) to verify both registered handlers are disposed on unmount
This commit is contained in:
@@ -138,8 +138,8 @@ describe('TabSubgraphInputs drag-and-drop', () => {
|
||||
|
||||
unmount()
|
||||
|
||||
expect(mockDraggableCleanup).toHaveBeenCalled()
|
||||
expect(mockDropTargetCleanup).toHaveBeenCalled()
|
||||
expect(mockDraggableCleanup).toHaveBeenCalledTimes(2)
|
||||
expect(mockDropTargetCleanup).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('calls movePromotion with correct indices when an item is dropped', () => {
|
||||
|
||||
@@ -177,7 +177,8 @@ function setDraggableState() {
|
||||
dropTargetForElements({
|
||||
element: item,
|
||||
onDrop: ({ source }) => {
|
||||
const fromIndex = source.data.index as number
|
||||
const fromIndex = source.data.index
|
||||
if (typeof fromIndex !== 'number') return
|
||||
if (fromIndex === index) return
|
||||
promotionStore.movePromotion(
|
||||
node.rootGraph.id,
|
||||
@@ -197,6 +198,7 @@ function setDraggableState() {
|
||||
watchDebounced(searchedWidgetsList, () => setDraggableState(), {
|
||||
debounce: 100
|
||||
})
|
||||
watch(promotionEntries, () => nextTick(setDraggableState))
|
||||
onMounted(() => setDraggableState())
|
||||
onBeforeUnmount(() => cleanupDragAndDrop())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user