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(webv2): space starred gallery accordion
joshistoast4758ad57d937
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsxindex bcc3b1bb2a..0bccfb18cb 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx@@ -33,7 +33,6 @@ import { userEvent } from 'vitest/browser';import type { GalleryStateView } from './galleryStateView';import type { GalleryActions, GalleryWidgetContextValue } from './GalleryWidgetContext';-import { GALLERY_GRID_GAP_PX } from './galleryGridLayout';import { GalleryImageGrid } from './GalleryImageGrid';import { GalleryWidgetContext } from './GalleryWidgetContext';@@ -501,16 +500,31 @@ describe('GalleryImageGrid mixed item cells', () => {expect(getComputedStyle(trigger).backgroundColor).toBe('rgba(0, 0, 0, 0)');});- it('adds a compact section gap after the last starred row', async () => {+ it('spaces the whole starred accordion away from the regular image grid', async () => {await renderGallery(createGallery({items: [createItem('image', 'starred.png', { starred: true }), createItem('image', 'regular.png')],}));- const options = mocks.virtualizerOptions.at(-1);+ const listRect = host?.querySelector('[role="list"]')?.getBoundingClientRect();+ const headerRect = getButton('Collapse starred items').parentElement?.getBoundingClientRect();+ const starredRect = getButton('Select starred.png for preview').getBoundingClientRect();+ const regularRect = getButton('Select regular.png for preview').getBoundingClientRect();++ expect((headerRect?.top ?? 0) - (listRect?.top ?? 0)).toBeCloseTo(8, 0);+ expect(starredRect.top - (headerRect?.bottom ?? 0)).toBeLessThan(4);+ expect(regularRect.top - starredRect.bottom).toBeCloseTo(8, 0);++ await click(getButton('Collapse starred items'));++ const collapsedHeaderRect = getButton('Expand starred items').parentElement?.getBoundingClientRect();+ const collapsedRegularRect = getButton('Select regular.png for preview').getBoundingClientRect();+ const collapsedSectionGap = collapsedRegularRect.top - (collapsedHeaderRect?.bottom ?? 0);- expect(options?.estimateSize(1)).toBe((options?.estimateSize(2) ?? 0) + GALLERY_GRID_GAP_PX);+ expect((collapsedHeaderRect?.top ?? 0) - (listRect?.top ?? 0)).toBeCloseTo(8, 0);+ expect(collapsedSectionGap).toBeGreaterThanOrEqual(8);+ expect(collapsedSectionGap).toBeLessThan(12);});it('collapses only the starred items and omits the disclosure when no stars are loaded', async () => {diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsxindex 1db794e594..63982c0eed 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx@@ -34,6 +34,7 @@ import { useGalleryGridSelection } from './useGalleryGridSelection';*/const viewportWidthCache = new Map<string, number>();const STARRED_HEADER_HEIGHT_PX = 24;+const STARRED_SECTION_GAP_PX = 8;const STARRED_TRIGGER_HOVER_STYLES = { color: 'fg' } as const;const dragEventContainsFiles = (event: DragEvent): boolean => Array.from(event.dataTransfer.types).includes('Files');@@ -147,17 +148,13 @@ export const GalleryImageGrid = () => {const row = rows[index];if (row?.kind === 'starred-header') {- return STARRED_HEADER_HEIGHT_PX;- }+ const nextRow = rows[index + 1];+ const isCollapsed = nextRow?.kind !== 'cells' || nextRow.section !== 'starred';- const nextRow = rows[index + 1];- const endsStarredSection =- row?.kind === 'cells' &&- row.section === 'starred' &&- nextRow?.kind === 'cells' &&- nextRow.section === 'regular';+ return STARRED_SECTION_GAP_PX + STARRED_HEADER_HEIGHT_PX + (isCollapsed ? STARRED_SECTION_GAP_PX : 0);+ }- return rowHeightPx + (endsStarredSection ? GALLERY_GRID_GAP_PX : 0);+ return rowHeightPx;},[rowHeightPx, rows]);@@ -332,7 +329,7 @@ export const GalleryImageGrid = () => {position="absolute"px="1"top="0"- transform={`translateY(${virtualRow.start}px)`}+ transform={`translateY(${virtualRow.start + STARRED_SECTION_GAP_PX}px)`}w="full"><chakra.button