Add drag-and-drop reordering for reference images#90
Conversation
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
lstein
left a comment
There was a problem hiding this comment.
In practice this does not seem to be working. I rebuilt the front end, reloaded the frontend on my browser (several times with the shift-key held down to force reload), added three images and then tried to reorder them by dragging.
The images dragged, but no vertical drop bar appeared and I couldn't reorder them. I think perhaps that the browser's drag-to-create-a-new-tab is interfering with the desired behavior?
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
The root cause was that the Fixed in b100f23 by adding |
|
@copilot Please add a log statement to the code (at the info level) so that I can verify that the order of the images is changing as expected. |
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Added in c59c814. After each reorder, the To see it in the browser console, enable logging via the InvokeAI settings (set log level to |
Summary
Some models (e.g. Flux.2 klein in edit mode) are sensitive to the order reference images are presented during inference. This adds drag-and-drop reordering to the Reference Image list so users can control that order.
Redux
refImagesReorderedaction torefImagesSlice— accepts an orderedids: string[]and rebuildsstate.entitiesin that orderDnD
singleRefImageDndSourcetodnd.ts— a dedicated source type for ref image reordering (ref images are not canvas entities, so they can't sharesingleCanvasEntityDndSource)Hook
useRefImageListDnd.ts— mirrorsuseCanvasEntityListDndbut usesleft/rightedge detection for the horizontal layoutComponent
RefImageList: each preview is now wrapped in aRefImageListItemthat attaches the DnD hook and renders aDndListDropIndicator(vertical drop line between items)monitorForElementseffect handles drops, callsreorderWithEdgewithaxis: 'horizontal', dispatchesrefImagesReordered, then flashes the moved itemBug fix
draggable={false}to the<img>element inRefImagePreviewto prevent the browser's native image drag (e.g. drag-to-new-tab) from intercepting the drag gesture and blocking pragmatic-drag-and-drop from activatingLogging
dndlogger namespace) after each reorder dispatch, emitting the new ordered list of ref image IDs so the reorder can be verified in the browser consoleRelated Issues / Discussions
QA Instructions
infoand thedndnamespace, then drag to reorder — the console will show aRef images reorderedmessage with the updatedreorderedIdsarray.Merge Plan
Checklist
What's Newcopy (if doing a release after this PR)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.