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
feat(layers): scroll-area tree, pinned-header clip, and brush row order
Josh Corbett5cb80d4ab3f6
diff --git a/invokeai/frontend/webv2/src/platform/ui/Scrollable.tsx b/invokeai/frontend/webv2/src/platform/ui/Scrollable.tsxindex 929d60ee2d..250ee89a62 100644--- a/invokeai/frontend/webv2/src/platform/ui/Scrollable.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/Scrollable.tsx@@ -6,6 +6,7 @@ import { useRef } from 'react';type ScrollAreaRootProps = ComponentProps<typeof ScrollArea.Root>;type ScrollAreaContentProps = ComponentProps<typeof ScrollArea.Content>;+type ScrollAreaViewportProps = ComponentProps<typeof ScrollArea.Viewport>;/*** zag pins `min-width: fit-content` *inline* on every scroll-area content box,@@ -29,6 +30,7 @@ export const Scrollable = ({contentProps,label,orientation = 'vertical',+ viewportProps,viewportRef,...rootProps}: ScrollAreaRootProps & {@@ -39,6 +41,8 @@ export const Scrollable = ({label?: string;/** Scroll axis; the scrollbar and content sizing follow it. Defaults to vertical. */orientation?: 'horizontal' | 'vertical';+ /** Extra props for the scrolling viewport itself, e.g. scroll/focus handlers. */+ viewportProps?: ScrollAreaViewportProps;/** The scrolling element itself — what a virtualizer needs to observe. */viewportRef?: RefObject<HTMLDivElement | null>;}) => {@@ -56,9 +60,10 @@ export const Scrollable = ({<ScrollArea.Viewportaria-label={label}h="full"- ref={resolvedViewportRef}role={label ? 'region' : undefined}w="full"+ {...viewportProps}+ ref={resolvedViewportRef}><ScrollArea.Contentstyle={orientation === 'horizontal' ? undefined : VERTICAL_CONTENT_STYLE}diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsxindex 15694c4865..4e8375714d 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx@@ -346,7 +346,7 @@ describe('LayersTree virtualization', () => {expect(thumbnailRequests).not.toHaveBeenCalled();resetLayerRowCommits();- const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.parentElement!;+ const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.closest<HTMLElement>('[data-part="viewport"]')!;await act(() => {scroller.scrollTop = 7;scroller.dispatchEvent(new Event('scroll'));@@ -434,7 +434,7 @@ describe('LayersTree keyboard and accessibility', () => {await act(() => userEvent.keyboard('{End}'));await settle();expect(document.activeElement).toBe(treeitem('Layer 1999'));- const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.parentElement!;+ const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.closest<HTMLElement>('[data-part="viewport"]')!;await act(() => {scroller.scrollTop = 0;scroller.dispatchEvent(new Event('scroll'));@@ -501,7 +501,7 @@ describe('LayersTree selection, surfaces and structure', () => {it('reveals a primary that changed outside the panel once, even inside a collapsed stack', async () => {await renderTree([layerContract('c1', 'control', { name: 'Control' }), ...manyLayers(2000)]);- const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.parentElement!;+ const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.closest<HTMLElement>('[data-part="viewport"]')!;expect(scroller.scrollTop).toBe(0);await act(() => dispatchExternal({ id: 'l1500', type: 'setCanvasSelectedLayer' }));await settle();@@ -542,7 +542,7 @@ describe('LayersTree selection, surfaces and structure', () => {it('scrolls the list while a drag rests in the edge band and asks the model once per target', async () => {await renderTree(manyLayers(200));- const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.parentElement!;+ const scroller = host!.querySelector<HTMLElement>('[role="tree"]')!.closest<HTMLElement>('[data-part="viewport"]')!;const first = host!.querySelector<HTMLElement>('[data-layer-row-id="l0"]')!;const start = centre(first);const rect = scroller.getBoundingClientRect();diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsxindex 6e0ddfb775..eb531aa4d3 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx@@ -9,7 +9,7 @@ import { Box, Text } from '@chakra-ui/react';import { DndContext, DragOverlay, pointerWithin, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';import { restrictToVerticalAxis } from '@dnd-kit/modifiers';import { useMountEffect } from '@platform/react/useMountEffect';-import { usePreservedScrollOffset } from '@platform/react/usePreservedScrollOffset';+import { Scrollable } from '@platform/ui/Scrollable';import { getDocumentIndex, getDocumentNode, lookupDocumentNodeState } from '@workbench/canvas-engine/api';import {publishLayerPanelSelection,@@ -169,7 +169,6 @@ export const LayersTree = ({const commitPrepared = usePreparedCommit(engine);const propertiesRequest = useCurrentLayerPropertiesRequest();const scrollRef = useRef<HTMLDivElement | null>(null);- usePreservedScrollOffset(scrollRef);const [scrollTop, setScrollTop] = useState(0);const [surface, setSurface] = useState<LayerSurfaceRequest | null>(null);const [renamingId, setRenamingId] = useState<string | null>(null);@@ -688,6 +687,10 @@ export const LayersTree = ({treeOwnsFocus.current = false;}}, []);+ const scrollViewportProps = useMemo(+ () => ({ onBlurCapture: handleBlurCapture, onFocusCapture: handleFocusCapture, onScroll: handleScroll }),+ [handleBlurCapture, handleFocusCapture, handleScroll]+ );useLayoutEffect(() => {const host = scrollRef.current;if (!host || !focusKey || !treeOwnsFocus.current || renamingId !== null) {@@ -1065,17 +1068,9 @@ export const LayersTree = ({onDragOver={handleDragOver}onDragStart={handleDragStart}>- <Box flex="1" minH="0" position="relative">- <Box- ref={scrollRef}- h="full"- overflowX="hidden"- overflowY="auto"- position="relative"- onBlurCapture={handleBlurCapture}- onFocusCapture={handleFocusCapture}- onScroll={handleScroll}- >+ {/* `overflow=hidden` clips the pinned header's push-out translate at the tree's edge. */}+ <Box flex="1" minH="0" overflow="hidden" position="relative">+ <Scrollable h="full" viewportProps={scrollViewportProps} viewportRef={scrollRef}><Boxaria-label={t('widgets.layers.tree')}aria-multiselectable="true"@@ -1178,7 +1173,7 @@ export const LayersTree = ({</Box>) : null}</Box>- </Box>+ </Scrollable>{pinnedHeader ? (<BoxborderBottomWidth="1px"diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsxindex 194d019549..ffd2a69efc 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx@@ -71,8 +71,8 @@ const ConnectedProperties = ({[['geometry', tool.geometry],['intensity', tool.intensity],- ['color', tool.color],['modes', tool.modes],+ ['color', tool.color],['more', tool.more],] as const).filter((entry): entry is [keyof typeof REGION_LABEL_KEYS, NonNullable<(typeof entry)[1]>] => !!entry[1]);