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.

feat(ui): keep a list row marked while its context menu is open

Josh Corbett9911079b70cc
diff --git a/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsx b/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsx
index 0574296594..d9f87439b2 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsx
@@ -97,6 +97,7 @@ export const ModelLibraryList = ({
fileSize={model.file_size}
format={model.format}
imageVersion={coverImageVersions[model.key]}
+ isMenuOpen={contextMenuTarget?.modelKey === model.key}
isMissing={missingModelKeys.has(model.key)}
isSelected={selectedKeys.has(model.key)}
modelKey={model.key}
@@ -147,6 +148,7 @@ interface ModelRowProps extends ListRowProps {
fileSize: number;
format: Parameters<typeof ModelFormatBadge>[0]['format'];
imageVersion?: number;
+ isMenuOpen: boolean;
isMissing: boolean;
isSelected: boolean;
modelKey: string;
diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx
index cd627acaf5..87d16b4bd1 100644
--- a/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx
+++ b/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx
@@ -55,6 +55,7 @@ export const NodePackList = ({
const renderItem = (pack: NodePackInfo, rowProps: ListRowProps) => (
<ListItem
{...rowProps}
+ isMenuOpen={contextMenuTarget?.pack.name === pack.name}
leading={
<Icon as={BlocksIcon} boxSize="4" color={rowProps.isActive ? 'accent.contrast' : 'fg.subtle'} flexShrink={0} />
}
diff --git a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx
index 3829562db6..10bfc77671 100644
--- a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx
@@ -93,6 +93,19 @@ describe('ListItem', () => {
expect(onContextMenu).toHaveBeenCalledTimes(1);
});
+ it('keeps the hover surface while its context menu is open', async () => {
+ const surface = () => getComputedStyle(primary().parentElement!).backgroundColor;
+
+ await userEvent.unhover(document.body);
+ await render(<ListItem title="A model" onContextMenu={vi.fn()} />);
+ const resting = surface();
+
+ await render(<ListItem isMenuOpen title="A model" onContextMenu={vi.fn()} />);
+
+ expect(resting).toBe('rgba(0, 0, 0, 0)');
+ expect(surface()).not.toBe(resting);
+ });
+
it('renders a static row without a press handler as plain content, not a button', async () => {
await render(<ListItem title="Read only" />);
diff --git a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsx b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsx
index 483772261b..4760674591 100644
--- a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsx
@@ -48,6 +48,8 @@ export interface ListItemProps {
isBusy?: boolean;
/** The row discloses content below itself; announced with aria-expanded. */
isExpanded?: boolean;
+ /** This row's context menu is open; the row keeps its hover surface so it is clear what the menu acts on. */
+ isMenuOpen?: boolean;
/** Accessible name of the checkbox when the title alone is ambiguous; defaults to "Select {title}". */
checkLabel?: string;
/** Identifies the row to its owning List for focus management. */
@@ -85,6 +87,7 @@ export const ListItem = ({
isBusy = false,
isChecked = false,
isExpanded,
+ isMenuOpen = false,
itemKey,
leading,
positionInSet,
@@ -197,7 +200,7 @@ export const ListItem = ({
css={styles.root}
data-busy={isBusy || undefined}
data-list-row={itemKey}
- data-static={isInteractive || tone !== 'none' ? undefined : ''}
+ data-menu-open={isMenuOpen || undefined}
role={role}
onContextMenu={onContextMenu ? handleContextMenu : undefined}
>
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
index db039fa223..c143e08204 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
@@ -900,14 +900,17 @@ const rowFocusRing = {
outlineOffset: '-2px',
} as const;
+/** Hover, extended to a row whose context menu is open so the row it acts on stays marked. */
+const ROW_POINTED = '&:is(:hover, [data-hover], [data-menu-open]):not(:disabled, [data-disabled])';
+
/** One row surface for every list-like control; `Row` and `ListItem` both build on it. */
const rowSurface = {
borderRadius: 'sm',
textAlign: 'start',
transition: 'background var(--wb-motion-duration-fast) ease, color var(--wb-motion-duration-fast) ease',
w: 'full',
- // Keep hover below selected emphasis so pointing does not resemble selection.
- _hover: { bg: 'bg.muted/60' },
+ // Keep the pointed fill below selected emphasis so pointing does not resemble selection.
+ [ROW_POINTED]: { bg: 'bg.muted/60' },
_disabled: { cursor: 'not-allowed', opacity: 0.5 },
} as const;
@@ -915,17 +918,17 @@ const rowSurface = {
const rowTones = {
none: {},
muted: { bg: 'bg.muted' },
- selected: { bg: 'bg.emphasized/60', _hover: { bg: 'bg.emphasized/60' } },
- emphasized: { bg: 'bg.emphasized', _hover: { bg: 'bg.emphasized' } },
+ selected: { bg: 'bg.emphasized/60', [ROW_POINTED]: { bg: 'bg.emphasized/60' } },
+ emphasized: { bg: 'bg.emphasized', [ROW_POINTED]: { bg: 'bg.emphasized' } },
brand: {
bg: 'brand.subtle',
color: 'brand.fg',
- _hover: { bg: 'brand.subtle' },
+ [ROW_POINTED]: { bg: 'brand.subtle' },
},
accent: {
bg: 'accent.solid',
color: 'accent.contrast',
- _hover: { bg: 'accent.solid' },
+ [ROW_POINTED]: { bg: 'accent.solid' },
},
} as const;
@@ -973,8 +976,6 @@ export const listItemSlotRecipe = defineSlotRecipe({
'&:has([data-list-primary]:focus-visible)': rowFocusRing,
// Rows of a page being replaced stay readable; only the pointer says the list is working.
'&[data-busy]': { cursor: 'progress' },
- // Nothing to press: pointing must not look like an affordance.
- '&[data-static]:hover': { bg: 'transparent' },
},
check: {
alignItems: 'center',