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): restore pane tab dividers while the panes are collapsed

Josh Corbett61e9f2c432f4
diff --git a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.browser.test.tsx
new file mode 100644
index 0000000000..1bc0e24b5f
--- /dev/null
+++ b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.browser.test.tsx
@@ -0,0 +1,58 @@
+import { ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, expect, it } from 'vitest';
+
+import { SegmentTabs } from './SegmentTabs';
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const TABS = [
+ { id: 'properties', label: 'Properties' },
+ { id: 'transform', label: 'Transform' },
+ { id: 'overview', label: 'Overview' },
+] as const;
+const noop = (): void => {};
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+
+afterEach(() => {
+ act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+/** Computed opacity of each divider between tabs, left to right, once transitions settle. */
+const dividerOpacities = async (showActivePanel: boolean): Promise<number[]> => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ act(() =>
+ root!.render(
+ <ChakraProvider value={system}>
+ <SegmentTabs
+ activeId="properties"
+ ariaLabel="Editor panes"
+ idBase="panes"
+ showActivePanel={showActivePanel}
+ tabs={TABS}
+ onSelect={noop}
+ />
+ </ChakraProvider>
+ )
+ );
+ const dividers = [...host.querySelectorAll<HTMLElement>('[role="tablist"] > [aria-hidden]')];
+ await Promise.all(dividers.flatMap((divider) => divider.getAnimations().map((animation) => animation.finished)));
+ return dividers.map((divider) => Number(getComputedStyle(divider).opacity));
+};
+
+it('hides only the dividers beside the shown tab', async () => {
+ expect(await dividerOpacities(true)).toEqual([0, 1]);
+});
+
+it('keeps every divider when the selected tab has no shown panel', async () => {
+ expect(await dividerOpacities(false)).toEqual([1, 1]);
+});
diff --git a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx
index a2e1f42039..ecf21cba92 100644
--- a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx
@@ -89,7 +89,8 @@ export const SegmentTabs = <T extends string>({
bg="border.emphasized"
flexShrink={0}
h="3.5"
- opacity={tab.id === activeId || tabs[index - 1]!.id === activeId ? 0 : 1}
+ // Only the shown tab's background replaces its neighbouring dividers; a collapsed strip keeps them all.
+ opacity={showActivePanel && (tab.id === activeId || tabs[index - 1]!.id === activeId) ? 0 : 1}
rounded="full"
transition="opacity var(--wb-motion-duration-fast)"
w="1px"