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(widgets): collapse from the keyboard at the panel floor

joshistoastc6315054d3bd
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx
index b271e96144..e061377d06 100644
--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx
@@ -174,9 +174,18 @@ export const WidgetPanelFrame = ({
}
event.preventDefault();
+
+ // Keyboard parity with the drag: a further collapse-ward step at the
+ // floor collapses, instead of silently clamping forever.
+ if (sizeChange < 0 && displaySizePx <= minPanelSizePx) {
+ layout.setRegionCollapsed(region, true);
+
+ return;
+ }
+
commitSize(displaySizePx + sizeChange);
},
- [commitSize, displaySizePx, isBottom, isLeft, maxPanelSizePx, minPanelSizePx]
+ [commitSize, displaySizePx, isBottom, isLeft, layout, maxPanelSizePx, minPanelSizePx, region]
);
const panelSizeProps = useMemo(
() => (isBottom ? { h: `${renderSizePx}px`, w: 'full' } : { h: 'full', w: `${renderSizePx}px` }),
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsx
index b003bfaf15..91ee80c341 100644
--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsx
@@ -215,6 +215,19 @@ describe('WidgetPanelFrame resize', () => {
expect(frameMocks.setRegionSize).toHaveBeenCalledExactlyOnceWith('left', 350);
});
+ it('collapses on a further collapse-ward key press at the floor', async () => {
+ frameMocks.sizePx = 350;
+ const separator = await renderFrame();
+
+ // Growing away from the floor is still a plain resize.
+ await interact(() => separator.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'ArrowRight' })));
+ expect(frameMocks.setRegionSize).toHaveBeenCalledExactlyOnceWith('left', 366);
+ expect(frameMocks.setRegionCollapsed).not.toHaveBeenCalled();
+
+ await interact(() => separator.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'ArrowLeft' })));
+ expect(frameMocks.setRegionCollapsed).toHaveBeenCalledExactlyOnceWith('left', true);
+ });
+
it('mirrors the axis and floor of the region it frames', async () => {
const rightSeparator = await renderFrame('right');