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
feat(ui): hide tab dividers beside a hovered segment tab
Josh Corbett3e3f1ae62748
diff --git a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.browser.test.tsxindex 1bc0e24b5f..1e244a38c6 100644--- a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.browser.test.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.browser.test.tsx@@ -3,6 +3,7 @@ import { system } from '@theme/system';import { act } from 'react';import { createRoot, type Root } from 'react-dom/client';import { afterEach, expect, it } from 'vitest';+import { userEvent } from 'vitest/browser';import { SegmentTabs } from './SegmentTabs';@@ -26,7 +27,7 @@ afterEach(() => {});/** Computed opacity of each divider between tabs, left to right, once transitions settle. */-const dividerOpacities = async (showActivePanel: boolean): Promise<number[]> => {+const dividerOpacities = async (showActivePanel: boolean, hoveredTab?: string): Promise<number[]> => {host = document.createElement('div');document.body.append(host);root = createRoot(host);@@ -44,6 +45,10 @@ const dividerOpacities = async (showActivePanel: boolean): Promise<number[]> =></ChakraProvider>));+ if (hoveredTab) {+ const tab = [...host.querySelectorAll<HTMLElement>('[role="tab"]')].find((el) => el.textContent === hoveredTab);+ await userEvent.hover(tab!);+ }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));@@ -56,3 +61,11 @@ it('hides only the dividers beside the shown tab', async () => {it('keeps every divider when the selected tab has no shown panel', async () => {expect(await dividerOpacities(false)).toEqual([1, 1]);});++it('hides the dividers beside a hovered tab as well as the shown one', async () => {+ expect(await dividerOpacities(true, 'Overview')).toEqual([0, 0]);+});++it('hides the dividers beside a hovered tab in a collapsed strip', async () => {+ expect(await dividerOpacities(false, 'Transform')).toEqual([0, 0]);+});diff --git a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsxindex 1459181d5e..89231ed02f 100644--- a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx@@ -7,6 +7,12 @@ import { Tooltip } from './Tooltip';const TAB_HOVER_PROPS = { bg: 'bg.hover', color: 'fg' };const TAB_SHOWN_BG = 'gray.hoverTint/15';+// A hovered tab's background replaces its neighbouring dividers, as the shown tab's does.+const TABLIST_CSS = {+ '& > [role="tab"]:hover + [data-segment-divider], & > [data-segment-divider]:has(+ [role="tab"]:hover)': {+ opacity: 0,+ },+};/** The strip's fixed height; collapsed blocks and drag snaps size against it. */export const SEGMENT_TABS_HEIGHT_PX = 40;@@ -74,6 +80,7 @@ export const SegmentTabs = <T extends string>({<HStackaria-label={ariaLabel}aria-orientation="horizontal"+ css={TABLIST_CSS}flex="1"gap="0.5"minW="0"@@ -87,6 +94,7 @@ export const SegmentTabs = <T extends string>({<Boxaria-hiddenbg="border.emphasized"+ data-segment-divider=""flexShrink={0}h="3.5"// Only the shown tab's background replaces its neighbouring dividers; a collapsed strip keeps them all.