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): centre the layer row visibility dot with its sibling controls

joshistoast96fd2efd4007
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsx
index 49dbaac04b..146fb50ab7 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.browser.test.tsx
@@ -197,6 +197,25 @@ describe('LayerListItem accessibility', () => {
expect(rect.height).toBeGreaterThanOrEqual(24);
});
+ it('sits the visibility dot on the same centre line as the other row controls', async () => {
+ // The dot lives in a wrapper Box that exists only to catch pointer events.
+ // As a block box that wrapper laid the button out on a text baseline, so
+ // descender space below it pushed the dot 3px above its siblings.
+ await renderHarness();
+
+ const centreY = (selector: string): number => {
+ const element = host!.querySelector<HTMLElement>(selector);
+ expect(element).not.toBeNull();
+ const rect = element!.getBoundingClientRect();
+ return rect.top + rect.height / 2;
+ };
+
+ const visibility = centreY('button[aria-label="Toggle visibility"]');
+ const lock = centreY('button[aria-label="Toggle lock"]');
+
+ expect(visibility).toBeCloseTo(lock, 1);
+ });
+
it('selects a layer with a pointer without requiring the drag handle', async () => {
await renderHarness();
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx
index a886ee3e51..ea75ee92b3 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx
@@ -345,7 +345,13 @@ export const LayerListItem = ({
) : (
<Box boxSize="6" />
)}
- <Box flexShrink="0" onClick={stopPropagation} onPointerDown={stopPropagation}>
+ {/*
+ `display="flex"` is load bearing, not cosmetic: as a block box this
+ wrapper lays its button out on a text baseline, and the descender
+ space below made it 30px tall and pushed the control 3px above the
+ centre line its sibling icon buttons sit on.
+ */}
+ <Box display="flex" flexShrink="0" onClick={stopPropagation} onPointerDown={stopPropagation}>
<ToggleDot
_before={layer.isEnabled ? VISIBILITY_DOT_CHECKED : VISIBILITY_DOT_UNCHECKED}
_focusVisible={ROW_SELECTION_FOCUS}
@@ -374,10 +380,10 @@ export const LayerListItem = ({
>
{layer.isLocked ? <LockIcon /> : <LockOpenIcon />}
</IconButton>
- <Box flexShrink="0" onClick={stopPropagation} onPointerDown={stopPropagation}>
+ <Box display="flex" flexShrink="0" onClick={stopPropagation} onPointerDown={stopPropagation}>
<LayerPropertiesPopover dispatch={dispatch} engine={engine} layer={layer} />
</Box>
- <Box flexShrink="0" onPointerDown={stopPropagation}>
+ <Box display="flex" flexShrink="0" onPointerDown={stopPropagation}>
<LayerContextMenu dispatch={dispatch} engine={engine} index={index} layer={layer} layers={layers} />
</Box>
</HStack>