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): stronger subtle tint, menu-like popover motion, scrolling selects
Josh Corbett02b6fc1d23c1
diff --git a/invokeai/frontend/webv2/src/platform/ui/Select.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/Select.browser.test.tsxnew file mode 100644index 0000000000..13f6509161--- /dev/null+++ b/invokeai/frontend/webv2/src/platform/ui/Select.browser.test.tsx@@ -0,0 +1,46 @@+import { ChakraProvider, createListCollection } from '@chakra-ui/react';+import { system } from '@theme/system';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';++import { Select } from './Select';++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++describe('Select', () => {+ let host: HTMLDivElement;+ let root: Root;+ const mount = (items: { label: string; value: string }[]) =>+ act(() => {+ root.render(+ <ChakraProvider value={system}>+ <Select aria-label="Scheduler" collection={createListCollection({ items })} />+ </ChakraProvider>+ );+ });+ const trigger = () => host.querySelector<HTMLButtonElement>('[data-scope="select"][data-part="trigger"]')!;++ beforeEach(() => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);+ });++ afterEach(async () => {+ await act(() => root.unmount());+ host.remove();+ });++ it('disables the trigger while the collection is empty, and opens once it has items', async () => {+ await mount([]);+ expect(trigger().disabled).toBe(true);+ await act(() => trigger().click());+ expect(document.querySelector('[role="listbox"]')).toBeNull();++ await mount([{ label: 'Euler', value: 'euler' }]);+ expect(trigger().disabled).toBe(false);+ await act(() => trigger().click());+ await expect.poll(() => document.querySelectorAll('[role="option"]').length).toBe(1);+ });+});diff --git a/invokeai/frontend/webv2/src/platform/ui/Select.tsx b/invokeai/frontend/webv2/src/platform/ui/Select.tsxindex b0d51e8078..7fbea6016c 100644--- a/invokeai/frontend/webv2/src/platform/ui/Select.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/Select.tsx@@ -44,15 +44,18 @@ const partitionByGroup = <T,>(return runs;};+/** Fits the anchor's available space with the same headroom the settings selects use. */+const DEFAULT_ITEMS_MAX_H = 'min(20rem, calc(var(--available-height) - 0.5rem))';+export interface SelectProps<T extends CollectionItem> extends Omit<SelectRootProps<T>, 'children'> {contentProps?: SelectContentProps;/**- * Caps the open menu's height and scrolls the items inside a Scrollable.- * The machine's own content-element scrolling is replaced by a- * `scrollToIndexFn` targeting the Scrollable viewport, so keyboard- * highlight, typeahead, and the open-reveal keep working.+ * Caps the open menu's height; the items scroll inside a Scrollable. The+ * machine's own content-element scrolling is replaced by a `scrollToIndexFn`+ * targeting the Scrollable viewport, so keyboard highlight, typeahead, and+ * the open-reveal keep working. `null` restores the machine's plain overflow.*/- itemsMaxH?: string;+ itemsMaxH?: string | null;/*** Renders labelled item groups: consecutive items with the same group key* share one header. Items must already be ordered by group.@@ -79,7 +82,7 @@ export const Select = <T extends CollectionItem>({getItemKey = getDefaultItemKey,groupBy,indicatorGroupProps,- itemsMaxH,+ itemsMaxH = DEFAULT_ITEMS_MAX_H,itemIndicator = true,portalled = true,positionerProps,@@ -100,7 +103,18 @@ export const Select = <T extends CollectionItem>({options?.[index]?.scrollIntoView({ block: 'nearest' });}, []);return (- <ChakraSelect.Root collection={collection} scrollToIndexFn={itemsMaxH ? scrollToIndexFn : undefined} {...rootProps}>+ // The items (and their Scrollable's scroll-area machine) mount only while+ // open: a widget carries many selects at rest, and the machine's observers+ // are per instance.+ <ChakraSelect.Root+ collection={collection}+ lazyMount+ scrollToIndexFn={itemsMaxH ? scrollToIndexFn : undefined}+ unmountOnExit+ {...rootProps}+ // An empty list is nothing to choose from: the trigger disables instead of opening a blank menu.+ disabled={rootProps.disabled || collection.items.length === 0}+ >{/* A real (visually hidden) Label part: the machine's trigger always pointsits aria-labelledby at this id, so a bare aria-label must materialize it —left on the Root it lands on a div, which ARIA prohibits. */}@@ -117,7 +131,7 @@ export const Select = <T extends CollectionItem>({<Portal disabled={!portalled}><ChakraSelect.Positioner {...positionerProps}><ChakraSelect.Content {...contentProps}>- <SelectItems ref={itemsRef} maxH={itemsMaxH}>+ <SelectItems ref={itemsRef} maxH={itemsMaxH ?? undefined}>{groupBy? partitionByGroup(collection.items, groupBy).map(({ group, items, startIndex }) => (<ChakraSelect.ItemGroup key={group}>diff --git a/invokeai/frontend/webv2/src/platform/ui/settings/SettingControl.tsx b/invokeai/frontend/webv2/src/platform/ui/settings/SettingControl.tsxindex b884e1bcfd..1fdff51a39 100644--- a/invokeai/frontend/webv2/src/platform/ui/settings/SettingControl.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/settings/SettingControl.tsx@@ -125,13 +125,12 @@ export const SettingControl = ({ field, surface, value, onChange, disabled, isMocollection={collection}value={selectValue}disabled={disabled}- size="sm"+ size={surface === 'quick' ? 'xs' : 'sm'}w={surface === 'quick' ? 'full' : DIALOG_CONTROL_WIDTH}flexShrink={0}portalled={false}// Fixed positioning escapes scrolling/clipped surfaces; staying inline preserves modal focus and ARIA.positioning={SELECT_POSITIONING}- itemsMaxH="min(18rem, calc(var(--available-height) - 0.5rem))"onValueChange={handleSelectChange}/>) : field.kind === 'slider' ? (diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.tsindex 446bcc13f2..b4944bc8a9 100644--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts@@ -79,6 +79,10 @@ export const popoverSlotRecipe = defineSlotRecipe({borderWidth: '1px',boxShadow: 'lg',color: 'fg',+ // The same drop-in motion as menus: Chakra's scale-fade reads as a+ // dialog, and its `fast` open lags behind the click on a busy workbench.+ _open: { animationStyle: 'slide-fade-in', animationDuration: 'faster' },+ _closed: { animationStyle: 'slide-fade-out', animationDuration: 'faster' },},arrowTip: {...chakraSlotRecipes.popover.base?.arrowTip,@@ -218,6 +222,15 @@ export const buttonRecipe = defineRecipe({...chakraRecipes.button.variants?.variant?.plain,_hover: { bg: 'colorPalette.hoverTint/10' },},+ // Chakra's subtle fill (`colorPalette.subtle`) is a step off the panel+ // surface, so a tinted button read as flat; the translucent tint keeps+ // the palette's hue legible on every surface.+ subtle: {+ ...chakraRecipes.button.variants?.variant?.subtle,+ bg: 'colorPalette.hoverTint/22',+ _hover: { bg: 'colorPalette.hoverTint/32' },+ _expanded: { bg: 'colorPalette.hoverTint/32' },+ },},} as unknown as typeof chakraRecipes.button.variants,});diff --git a/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsx b/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsxindex 7443ce8bbc..a4b9e90f2d 100644--- a/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsx@@ -370,18 +370,21 @@ const CompactBottomWidget = ({display="flex"flexDirection="column"maxH="min(28rem, var(--available-height))"- overflow="hidden"p="0"w="26rem">- {item.instance ? (- <WidgetRendererById- instanceId={item.id}- widget={item.widget}- presentation="expanded"- region="popover"- />- ) : null}+ {/* Clipping lives one level down: `overflow: hidden` on the+ content itself would cut off the anchor arrow. */}+ <Box display="flex" flex="1" flexDirection="column" minH="0" overflow="hidden" rounded="inherit">+ {item.instance ? (+ <WidgetRendererById+ instanceId={item.id}+ widget={item.widget}+ presentation="expanded"+ region="popover"+ />+ ) : null}+ </Box></PopoverContent></Popover.Positioner></Portal>