Skip to content

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.

fix(webv2): wrap detail panel workflow titles instead of truncating

joshistoast6d998e2c1ea3
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx
index 3c2913a1ed..1acb2b7cb2 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx
@@ -25,7 +25,6 @@ import {
} from '@platform/state/accountLifecycle';
import { getApiErrorMessage } from '@platform/transport/http';
import { Button, ConfirmDialog, IconButton, MenuContent, Scrollable } from '@platform/ui';
-import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import {
CopyIcon,
DownloadIcon,
@@ -349,7 +348,15 @@ export const WorkflowLibraryDetailPanel = ({
) : null}
</Stack>
- <MiddleTruncate fontSize="sm" fontWeight="600" minW="0" text={name} />
+ {/* The one place the whole name has to be readable — the rail is what
+ the user consults before opening a workflow, so it wraps instead
+ of truncating. `anywhere` so a delimiter-free name breaks too;
+ containment is the wrap plus the scroll area's zeroed content
+ min-width, not a clamp. (Grid cards still truncate: there the name
+ is a glance, not the answer.) */}
+ <Text fontSize="sm" fontWeight="600" minW="0" overflowWrap="anywhere">
+ {name}
+ </Text>
{item.description ? (
<Text color="fg.muted" fontSize="2xs" lineClamp={4}>
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx
index 2fa200f509..06c597afb9 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx
@@ -805,7 +805,7 @@ describe('WorkflowLibraryDialog', () => {
expect(closeBox?.left ?? 0).toBeGreaterThanOrEqual(segmentBox?.right ?? 0);
});
- it('truncates a long workflow name instead of scrolling the rail sideways', async () => {
+ it('wraps a long workflow name in full instead of scrolling the rail sideways', async () => {
await openWith(withSnapshot({ entries: [LONG_NAMED, PORTRAIT] }));
const detail = document.querySelector<HTMLElement>('[data-workflow-detail]');
@@ -824,8 +824,13 @@ describe('WorkflowLibraryDialog', () => {
expect(railViewport).not.toBeNull();
expect(railViewport?.scrollWidth).toBeLessThanOrEqual((railViewport?.clientWidth ?? 0) + 1);
- // The name is still readable — truncated, with the full string on hover.
- expect(detail?.querySelector(`[title="${LONG_NAME}"]`)).not.toBeNull();
+ // The rail is where the user decides whether to open a workflow, so the
+ // whole name is on screen — wrapped over several lines, never clipped.
+ const heading = [...(detail?.querySelectorAll('p') ?? [])].find((element) => element.textContent === LONG_NAME);
+ expect(heading, 'the full name should be rendered').not.toBeUndefined();
+ expect(heading?.scrollWidth).toBeLessThanOrEqual((heading?.clientWidth ?? 0) + 1);
+ // Wrapped, not squeezed onto one line.
+ expect(heading?.getBoundingClientRect().height ?? 0).toBeGreaterThan(20);
});
it('shows the busy overlay while a workflow is being applied', async () => {
diff --git a/invokeai/frontend/webv2/src/platform/ui/Scrollable.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/Scrollable.browser.test.tsx
new file mode 100644
index 0000000000..7a2cb5725a
--- /dev/null
+++ b/invokeai/frontend/webv2/src/platform/ui/Scrollable.browser.test.tsx
@@ -0,0 +1,68 @@
+import { ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { act, type ReactNode } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it } from 'vitest';
+
+import { Scrollable } from './Scrollable';
+
+/**
+ * zag pins `min-width: fit-content` inline on the scroll-area content box. A
+ * horizontal strip needs that; a vertical area must not inherit it, because it
+ * renders no horizontal scrollbar — anything pushed sideways there is simply
+ * unreachable. These two tests are the whole contract.
+ */
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+afterEach(async () => {
+ await act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+/** No spaces and no hyphens: nothing the layout can break on, so it contributes its whole width to min-content. */
+const UNBREAKABLE = 'AVeryLongUnbreakableWorkflowNameThatHasNowhereToWrap';
+
+const renderScrollable = async (children: ReactNode, orientation: 'horizontal' | 'vertical'): Promise<HTMLElement> => {
+ host = document.createElement('div');
+ host.style.cssText = 'width:200px;height:80px;';
+ document.body.append(host);
+ root = createRoot(host);
+
+ await act(() => {
+ root?.render(
+ <ChakraProvider value={system}>
+ <Scrollable label="subject" orientation={orientation}>
+ {children}
+ </Scrollable>
+ </ChakraProvider>
+ );
+ });
+
+ return host.querySelector<HTMLElement>('[role="region"][aria-label="subject"]')!;
+};
+
+describe('Scrollable', () => {
+ it('does not let a vertical area scroll sideways, whatever its content asks for', async () => {
+ const viewport = await renderScrollable(<div>{UNBREAKABLE}</div>, 'vertical');
+
+ expect(viewport.clientWidth).toBeGreaterThan(0);
+ expect(viewport.scrollWidth).toBeLessThanOrEqual(viewport.clientWidth + 1);
+ });
+
+ it('still lets a horizontal strip outgrow its viewport', async () => {
+ const viewport = await renderScrollable(
+ <div style={{ display: 'flex', whiteSpace: 'nowrap' }}>
+ {UNBREAKABLE}
+ {UNBREAKABLE}
+ </div>,
+ 'horizontal'
+ );
+
+ expect(viewport.scrollWidth).toBeGreaterThan(viewport.clientWidth);
+ });
+});