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): align focus outline with widget edge

joshistoast2c3b8e807618
diff --git a/invokeai/frontend/webv2/src/workbench/focusRegions.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/focusRegions.browser.test.tsx
new file mode 100644
index 0000000000..e453a91baf
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/focusRegions.browser.test.tsx
@@ -0,0 +1,51 @@
+import { Box, ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+vi.mock('./settings/store', () => ({
+ useWorkbenchPreferenceSelector: (selector: (preferences: { showFocusRegionHighlight: boolean }) => unknown) =>
+ selector({ showFocusRegionHighlight: true }),
+}));
+
+import { FocusRegionProvider, useFocusRegionProps } from './focusRegions';
+
+const FocusableRegion = () => <Box data-testid="focus-region" h="20" {...useFocusRegionProps('center')} />;
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+afterEach(async () => {
+ await act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+describe('focus region highlight', () => {
+ it('draws the highlight at the widget edge', async () => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+
+ await act(() => {
+ root?.render(
+ <ChakraProvider value={system}>
+ <FocusRegionProvider>
+ <FocusableRegion />
+ </FocusRegionProvider>
+ </ChakraProvider>
+ );
+ });
+
+ const region = host.querySelector<HTMLElement>('[data-testid="focus-region"]');
+ expect(region).not.toBeNull();
+
+ await act(() => region?.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true })));
+
+ expect(region?.getAttribute('data-highlighted')).toBe('true');
+ expect(getComputedStyle(region!, '::after').inset).toBe('0px');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/focusRegions.tsx b/invokeai/frontend/webv2/src/workbench/focusRegions.tsx
index 970c449c1e..bae0f3f04f 100644
--- a/invokeai/frontend/webv2/src/workbench/focusRegions.tsx
+++ b/invokeai/frontend/webv2/src/workbench/focusRegions.tsx
@@ -27,7 +27,7 @@ const highlightStyles = {
borderColor: 'transparent',
borderRadius: 'md',
content: '""',
- inset: '2px',
+ inset: '0',
opacity: 0,
pointerEvents: 'none',
position: 'absolute',