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(gallery): prioritize current-image focus and skip inert tiles
Josh Corbettc60a05c0ea94
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 8136600bb2..e2fa004b3e 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@@ -1532,6 +1532,38 @@ describe('shared gallery progress section', () => {expect(tile.getAttribute('aria-label')).toContain('Queued');}});+ it('restores focus to the current image ahead of an earlier starred thumbnail', async () => {+ currentProgressSessions = [session];+ currentLiveFollowEnabled = true;+ setStrip([createItem('image', 'starred.png', { starred: true })]);+ const gallery = createGallery({ selectedItemKey: 'image:last.png', selectedItemKeys: ['image:last.png'] });+ await renderGallery(gallery);+ host!.querySelector<HTMLButtonElement>('button[title^="Workflow A ·"]')!.focus();+ currentProgressSessions = [];+ await renderGallery(gallery);+ const current = host!.querySelector('button[aria-current="true"]');+ expect(current).not.toBeNull();+ expect(current).not.toBe(host!.querySelector('[role="listitem"] button'));+ expect(document.activeElement).toBe(current);+ });+ it('tabs through running previews and skips queued and settling tiles', async () => {+ currentProgressSessions = [+ { ...session, id: 'run:2', state: 'queued' },+ session,+ { ...session, id: 'run:3', state: 'settling' },+ ];+ await renderGallery();+ host!.querySelector<HTMLButtonElement>('[data-progress-disclosure]')!.focus();+ await act(() => userEvent.tab());+ expect(document.activeElement).toBe(host!.querySelector('button[aria-label$="Preparing"]'));+ await act(() => userEvent.tab());+ expect(document.activeElement?.closest('[role="listitem"]')).not.toBeNull();+ for (const tile of host!.querySelectorAll<HTMLButtonElement>(+ '[aria-label="In progress"] button[aria-disabled="true"]'+ )) {+ expect(tile.tabIndex).toBe(-1);+ }+ });it('collapses independently and restores focus when the last session disappears', async () => {currentProgressSessions = [session];await renderGallery();diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryProgressSection.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryProgressSection.tsxindex 0119938f02..11efef36c0 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryProgressSection.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryProgressSection.tsx@@ -34,7 +34,9 @@ export const GalleryProgressSection = ({const viewport = getScrollElement();const target =root?.querySelector<HTMLButtonElement>('[data-progress-disclosure]') ??- viewport?.querySelector<HTMLElement>('button[aria-current="true"], [role="listitem"] button, [role="button"]') ??+ viewport?.querySelector<HTMLElement>('button[aria-current="true"]') ??+ viewport?.querySelector<HTMLElement>('[role="listitem"] button') ??+ viewport?.querySelector<HTMLElement>('[role="button"]') ??viewport;target?.focus({ preventScroll: true });}, [getScrollElement]);@@ -63,55 +65,47 @@ export const GalleryProgressSection = ({return (<Box ref={rootRef} aria-label={t('widgets.gallery.inProgress')} flexShrink={0} minW="0" role="region">- {visible ? (- <>- <chakra.button- ref={disclosureRef}- display="flex"- alignItems="center"- aria-controls={contentId}- aria-expanded={!progressSectionCollapsed}- type="button"- focusVisibleRing="inside"- data-progress-disclosure- gap="1"- h={`${layout.headerHeight}px`}- py="0"- px="1"- textAlign="start"- title={t('widgets.gallery.progressShared')}- w="full"- onClick={toggleCollapsed}- >- <Icon- as={ChevronRightIcon}- boxSize="3"- transform={progressSectionCollapsed ? undefined : 'rotate(90deg)'}- />- <Icon as={HourglassIcon} boxSize="3" />- <Text fontSize="2xs" fontWeight="600" letterSpacing="wide" lineHeight="1" textTransform="uppercase">- {t('widgets.gallery.inProgress')}- </Text>- <Text color="fg.muted" fontSize="xs" fontVariantNumeric="tabular-nums">- · {progressSessions.length}- </Text>- </chakra.button>- <Box id={contentId} hidden={progressSectionCollapsed}>- {!progressSectionCollapsed ? (- <GalleryProgressGrid- sessions={progressSessions}- layout={layout}- fit={gallery.settings.thumbnailFit}- getScrollElement={getScrollElement}- pinnedSessionId={pinnedProgressSessionId}- liveFollowEnabled={liveFollowEnabled}- onFollow={followProgressSession}- restoreFocus={restoreFocus}- />- ) : null}- </Box>- </>- ) : null}+ <chakra.button+ ref={disclosureRef}+ display="flex"+ alignItems="center"+ aria-controls={contentId}+ aria-expanded={!progressSectionCollapsed}+ type="button"+ focusVisibleRing="inside"+ data-progress-disclosure+ gap="1"+ h={`${layout.headerHeight}px`}+ py="0"+ px="1"+ textAlign="start"+ title={t('widgets.gallery.progressShared')}+ w="full"+ onClick={toggleCollapsed}+ >+ <Icon as={ChevronRightIcon} boxSize="3" transform={progressSectionCollapsed ? undefined : 'rotate(90deg)'} />+ <Icon as={HourglassIcon} boxSize="3" />+ <Text fontSize="2xs" fontWeight="600" letterSpacing="wide" lineHeight="1" textTransform="uppercase">+ {t('widgets.gallery.inProgress')}+ </Text>+ <Text color="fg.muted" fontSize="xs" fontVariantNumeric="tabular-nums">+ · {progressSessions.length}+ </Text>+ </chakra.button>+ <Box id={contentId} hidden={progressSectionCollapsed}>+ {!progressSectionCollapsed ? (+ <GalleryProgressGrid+ sessions={progressSessions}+ layout={layout}+ fit={gallery.settings.thumbnailFit}+ getScrollElement={getScrollElement}+ pinnedSessionId={pinnedProgressSessionId}+ liveFollowEnabled={liveFollowEnabled}+ onFollow={followProgressSession}+ restoreFocus={restoreFocus}+ />+ ) : null}+ </Box></Box>);};@@ -238,6 +232,7 @@ const GalleryProgressTile = ({aria-label={`${label} · ${status}`}aria-pressed={selected && session.state !== 'queued'}aria-disabled={session.state !== 'running'}+ tabIndex={session.state === 'running' ? 0 : -1}borderColor={selected && session.state !== 'queued' ? 'accent.solid' : 'border.subtle'}borderWidth="1px"flexShrink={0}