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): square the icon-only prompt action buttons
joshistoastc5c2a08b964e
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsxindex 68b8807f56..f5348c3c73 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsx@@ -144,6 +144,23 @@ describe('dynamic prompts in the positive prompt field', () => {await expectRowInteractionStylesToMatch(expected, row, hoverBackgroundColor);});+ it('stays square while it carries no count, and widens only to fit one', async () => {+ // Passing `px={undefined}` reads as "leave the default", but it is spread+ // over Chakra's own `px: '0'` and clobbers it, so the icon-only button used+ // to sit 8px wider than the square buttons either side of it.+ await render('a plain cat');+ const plain = findButton().getBoundingClientRect();++ expect(plain.width).toBeCloseTo(plain.height, 1);++ await act(() => root?.unmount());+ host?.remove();+ await render('a {red|green} cat');+ await vi.waitFor(() => expect(findButton().textContent).toContain('2'));++ expect(findButton().getBoundingClientRect().width).toBeGreaterThan(plain.width);+ });+it('stays inert and never expands a prompt with no dynamic syntax', async () => {await render('a plain cat');diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsxindex 6a8e4acf37..9a502941d3 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.tsx@@ -84,7 +84,11 @@ export const DynamicPromptsButton = ({aria-label={t('widgets.generate.dynamicPrompts.showPrompts')}color={expansion.isError ? 'fg.error' : undefined}opacity={expansion.isDynamic ? undefined : 0.5}- px={countLabel ? '1' : undefined}+ // `undefined` is not "leave it alone": Chakra's IconButton spreads+ // incoming props over its own `px: '0'`, so an explicit undefined+ // clobbers it and the size recipe's `px: '2'` padded the icon-only+ // button out to 32x24 beside its 24x24 neighbours.+ px={countLabel ? '1' : '0'}size="2xs"variant="ghost"w={countLabel ? 'auto' : undefined}diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsxindex 2680f9e7d9..42c2e50a71 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsx@@ -112,6 +112,22 @@ describe('the prompt templates button', () => {expect(getComputedStyle(name!).opacity).toBe('0.5');});+ it('stays square with nothing applied, and widens only to carry a name', async () => {+ // `px={undefined}` looks like "leave the default" but is spread over+ // Chakra's own `px: '0'`, clobbering it — the icon-only button used to be+ // 8px wider than the square buttons beside it.+ await render(null);+ const bare = host!.querySelector('button')!.getBoundingClientRect();++ expect(bare.width).toBeCloseTo(bare.height, 1);++ await act(() => root?.unmount());+ host?.remove();+ await render(applied);++ expect(host!.querySelector('button')!.getBoundingClientRect().width).toBeGreaterThan(bare.width);+ });+it('says nothing while the catalog is unread', async () => {usePromptTemplates.mockReturnValue({ ...catalog, isLoaded: false });await render(applied);diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.tsxindex 46a1b5dd02..f71e958a43 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.tsx@@ -117,7 +117,11 @@ export const PromptTemplatesButton = ({// Quiet states only: a dimmed icon when nothing is applied, the// template's name beside it when one is. No accent, no motion.opacity={activeTemplate ? undefined : 0.5}- px={activeTemplate ? '1' : undefined}+ // Explicit `'0'`, not `undefined`: Chakra's IconButton spreads+ // incoming props over its own `px: '0'`, so undefined clobbers it+ // and the size recipe's `px: '2'` widened the icon-only button past+ // the square neighbours it sits beside.+ px={activeTemplate ? '1' : '0'}size="2xs"variant="ghost"w={activeTemplate ? 'auto' : undefined}