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): show starred state on the image context menu star

joshistoast9617f77945c8
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsx
index 3ef8601cd2..19df4a928f 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsx
@@ -268,6 +268,63 @@ describe('ImageContextMenu deletion confirmation', () => {
});
});
+describe('ImageContextMenu starred state', () => {
+ const starIconFill = (label: string): string =>
+ getComputedStyle(document.querySelector<HTMLElement>(`[aria-label="${label}"] svg`)!).fill;
+
+ it('fills the star for a starred item and leaves it outlined otherwise', async () => {
+ // Lucide is stroke-only, so an unfilled star was the *only* thing shown for
+ // both states — the text label was carrying all of the meaning.
+ const unstarred = item('image', 'plain.png');
+ await renderItemMenu(createActions(vi.fn()), {
+ itemRefs: [{ kind: 'image', name: unstarred.name }],
+ items: [unstarred],
+ x: 20,
+ y: 20,
+ });
+
+ expect(starIconFill('Star image')).toBe('none');
+
+ await interact(() => root?.unmount());
+ host?.remove();
+
+ const starred = { ...item('image', 'fave.png'), starred: true };
+ await renderItemMenu(createActions(vi.fn()), {
+ itemRefs: [{ kind: 'image', name: starred.name }],
+ items: [starred],
+ x: 20,
+ y: 20,
+ });
+
+ expect(starIconFill('Unstar image')).not.toBe('none');
+ });
+
+ it('fills the bulk star only once every selected item is starred', async () => {
+ const mixed = [item('image', 'a.png'), { ...item('image', 'b.png'), starred: true }];
+ await renderItemMenu(createActions(vi.fn()), {
+ itemRefs: mixed.map((entry) => ({ kind: 'image' as const, name: entry.name })),
+ items: mixed,
+ x: 20,
+ y: 20,
+ });
+
+ expect(getComputedStyle(getMenuItem('Star All').querySelector('svg')!).fill).toBe('none');
+
+ await interact(() => root?.unmount());
+ host?.remove();
+
+ const allStarred = mixed.map((entry) => ({ ...entry, starred: true }));
+ await renderItemMenu(createActions(vi.fn()), {
+ itemRefs: allStarred.map((entry) => ({ kind: 'image' as const, name: entry.name })),
+ items: allStarred,
+ x: 20,
+ y: 20,
+ });
+
+ expect(getComputedStyle(getMenuItem('Unstar All').querySelector('svg')!).fill).not.toBe('none');
+ });
+});
+
describe('ImageContextMenu mixed-media action visibility', () => {
it('shows common actions for a single video and hides every image-only action', async () => {
const video = item('video', 'clip.mp4');
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.tsx
index 9fc4ed34cc..9ecb548a47 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.tsx
@@ -379,6 +379,7 @@ const SingleItemMenuItems = ({
<QuickMenuItem icon={EyeIcon} label="Open in preview" value="open-in-preview" onClick={handleOpenPreview} />
<QuickMenuItem
icon={StarIcon}
+ iconFill={item.starred ? 'currentColor' : 'none'}
label={`${item.starred ? 'Unstar' : 'Star'} ${mediaLabel}`}
value="toggle-starred"
onClick={handleToggleStarred}
@@ -471,6 +472,7 @@ const BulkItemMenuItems = ({
<Menu.Separator borderColor="border.subtle" />
<ContextMenuItem
icon={StarIcon}
+ iconFill={allStarred ? 'currentColor' : 'none'}
label={allStarred ? 'Unstar All' : 'Star All'}
value="toggle-starred-all"
onClick={handleToggleStarred}
@@ -793,6 +795,7 @@ const ToggleStarQuickMenuItem = ({ actions, image }: { actions: ImageActions; im
return (
<QuickMenuItem
icon={StarIcon}
+ iconFill={image.starred ? 'currentColor' : 'none'}
label={image.starred ? 'Unstar image' : 'Star image'}
value="toggle-starred"
onClick={handleClick}
@@ -833,6 +836,7 @@ const BulkMenuItems = ({
<Menu.Separator borderColor="border.subtle" />
<ContextMenuItem
icon={StarIcon}
+ iconFill={allStarred ? 'currentColor' : 'none'}
label={allStarred ? 'Unstar All' : 'Star All'}
value="toggle-starred-all"
onClick={handleToggleStarred}
@@ -999,11 +1003,14 @@ const ContextSubMenu = ({
const QuickMenuItem = ({
icon,
+ iconFill,
label,
value,
onClick,
}: {
icon: LucideIcon;
+ /** Lucide icons are stroke-only, so `'currentColor'` is how an on state reads. */
+ iconFill?: string;
label: string;
value: string;
onClick: () => void;
@@ -1016,7 +1023,7 @@ const QuickMenuItem = ({
positioning={QUICK_MENU_TOOLTIP_POSITIONING_PROPS}
>
<Menu.Item aria-label={label} flex="1" justifyContent="center" value={value} onClick={onClick}>
- <Icon as={icon} boxSize="4" color="fg" />
+ <Icon as={icon} boxSize="4" color="fg" fill={iconFill} />
</Menu.Item>
</Tooltip>
);
@@ -1025,6 +1032,7 @@ const ContextMenuItem = ({
color,
disabled,
icon,
+ iconFill,
label,
value,
onClick,
@@ -1032,13 +1040,15 @@ const ContextMenuItem = ({
color?: string;
disabled?: boolean;
icon: LucideIcon;
+ /** Lucide icons are stroke-only, so `'currentColor'` is how an on state reads. */
+ iconFill?: string;
label: string;
value: string;
onClick?: () => void;
}) => (
<Menu.Item color={color} disabled={disabled} value={value} onClick={onClick}>
<HStack gap="2" minW="0" w="full">
- <Icon as={icon} boxSize="3.5" color={color ?? 'fg.subtle'} flexShrink={0} />
+ <Icon as={icon} boxSize="3.5" color={color ?? 'fg.subtle'} fill={iconFill} flexShrink={0} />
<Text flex="1" fontSize="xs">
{label}
</Text>