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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(ui): stop preset drag scrolling
joshistoastcddf17d4884f
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.tsxindex 394ff37305..72e5bae29c 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@@ -225,7 +225,7 @@ describe('LayoutPresetStrip', () => {await act(() => mouse('mouseup', source!.ownerDocument, edgeX, startY));});- it('auto-scrolls only an overflowing strip and stops when the drag ends', async () => {+ it('keeps an overflowing strip stationary while dragging near its right edge', async () => {for (let index = 2; index <= 8; index += 1) {store.commands.layout.createPreset(`custom-${index}`, `Custom ${index}`, 'star');}@@ -251,7 +251,7 @@ describe('LayoutPresetStrip', () => {}));- expect(scrollContainer!.scrollLeft).toBeGreaterThan(0);+ expect(scrollContainer!.scrollLeft).toBe(0);await act(() => mouse('mouseup', source!.ownerDocument, edgeX, startY));const scrollLeftAfterDrop = scrollContainer!.scrollLeft;@@ -262,7 +262,8 @@ describe('LayoutPresetStrip', () => {}));- expect(scrollContainer!.scrollLeft).toBe(scrollLeftAfterDrop);+ expect(scrollLeftAfterDrop).toBe(0);+ expect(scrollContainer!.scrollLeft).toBe(0);});it('preserves horizontal touch panning and reorders after a long press', async () => {diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsxindex 9ced5985d4..83139e20c0 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx@@ -1,4 +1,4 @@-import type { AutoScrollOptions, DragEndEvent } from '@dnd-kit/core';+import type { DragEndEvent } from '@dnd-kit/core';import type { LayoutPreset, LayoutPresetId } from '@workbench/layoutContracts';import type { Project } from '@workbench/projectContracts';import type { KeyboardEvent, MouseEvent } from 'react';@@ -39,7 +39,7 @@ import {SettingsIcon,Trash2Icon,} from 'lucide-react';-import { useCallback, useMemo, useRef, useState } from 'react';+import { useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import type { LayoutPresetDialogValue } from './layoutPresetDialogModel';@@ -75,7 +75,6 @@ export const LayoutPresetStrip = () => {const { t } = useTranslation();const { activePreset, hasDrifted } = useLayoutDrift();const { layout } = useWorkbenchCommands();- const scrollContainerRef = useRef<HTMLDivElement>(null);const [isSaveAsOpen, setIsSaveAsOpen] = useState(false);const [menuTarget, setMenuTarget] = useState<{ anchor: DOMRect; preset: LayoutPreset } | null>(null);@@ -93,12 +92,6 @@ export const LayoutPresetStrip = () => {useSensor(TouchSensor, TOUCH_SENSOR_OPTIONS),useSensor(KeyboardSensor, KEYBOARD_SENSOR_OPTIONS));- const autoScroll = useMemo<AutoScrollOptions>(- () => ({- canScroll: (element) => element === scrollContainerRef.current && element.scrollWidth > element.clientWidth,- }),- []- );const saveAsDefaultRoute = useMemo(() => ({ destination: invocation.destination, sourceId: invocation.sourceId }),[invocation.destination, invocation.sourceId]@@ -145,17 +138,10 @@ export const LayoutPresetStrip = () => {return (<><HStack gap="1" justify="center" maxW="min(36vw, 44rem)" minW="0">- <Box- ref={scrollContainerRef}- css={PRESET_SCROLL_CSS}- data-layout-preset-scroll=""- maxW="full"- minW="0"- overflowX="auto"- >+ <Box css={PRESET_SCROLL_CSS} data-layout-preset-scroll="" maxW="full" minW="0" overflowX="auto"><DndContextaccessibility={dndAccessibility}- autoScroll={autoScroll}+ autoScroll={false}collisionDetection={closestCenter}modifiers={DND_MODIFIERS}sensors={sensors}