Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(ui): stop preset drag scrolling

joshistoast80036bb1bbad
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx
index 3c1b981d04..b62d02a625 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx
@@ -133,4 +133,35 @@ describe('LayoutPresetStrip', () => {
expect(store.getSnapshot().account.layoutPresetOrder).toEqual(['custom-1', 'edit', 'automate', 'compose']);
expect(store.getSnapshot().activeProject.layout.presetId).toBe(activeBeforeDrag);
});
+
+ it('does not auto-scroll the strip while dragging near its right edge', async () => {
+ for (let index = 2; index <= 8; index += 1) {
+ store.commands.layout.createPreset(`custom-${index}`, `Custom ${index}`, 'star');
+ }
+ await renderStrip();
+ const scrollContainer = document.querySelector<HTMLElement>('[data-layout-preset-scroll]');
+ const source = presetTab('compose');
+ expect(scrollContainer).not.toBeNull();
+ expect(source).not.toBeNull();
+ expect(scrollContainer!.scrollWidth).toBeGreaterThan(scrollContainer!.clientWidth);
+ const sourceRect = source!.getBoundingClientRect();
+ const containerRect = scrollContainer!.getBoundingClientRect();
+ const startX = sourceRect.left + sourceRect.width / 2;
+ const startY = sourceRect.top + sourceRect.height / 2;
+ const edgeX = containerRect.right - 2;
+
+ await act(() => pointer('pointerdown', source!, startX, startY));
+ await act(() => pointer('pointermove', source!.ownerDocument, startX + 8, startY));
+ await act(() => pointer('pointermove', source!.ownerDocument, edgeX, startY));
+ await act(
+ () =>
+ new Promise<void>((resolve) => {
+ globalThis.setTimeout(resolve, 150);
+ })
+ );
+
+ expect(scrollContainer!.scrollLeft).toBe(0);
+
+ await act(() => pointer('pointerup', source!.ownerDocument, edgeX, startY));
+ });
});
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx
index 5df77fe3a8..26511beea3 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx
@@ -120,6 +120,7 @@ export const LayoutPresetStrip = () => {
<HStack gap="1" justify="center" maxW="min(36vw, 44rem)" minW="0">
<Box css={PRESET_SCROLL_CSS} data-layout-preset-scroll="" maxW="full" minW="0" overflowX="auto">
<DndContext
+ autoScroll={false}
collisionDetection={closestCenter}
modifiers={DND_MODIFIERS}
sensors={sensors}