mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): fix panel resize bug
A bug that caused panels to be collapsed on a fresh indexedDb in was fixed in dd32c632cd
, but this re-introduced a different bug that caused the panels to expand on window resize, if they were already collapsed.
Revert the previous change and instead add one imperative resize outside the observer, so that on startup, we set both panels to their minimum sizes.
This commit is contained in:
parent
fe5bceb1ed
commit
895cb8637e
@ -125,8 +125,11 @@ export const usePanel = (arg: UsePanelOptions): UsePanelReturn => {
|
||||
|
||||
_setMinSize(minSizePct);
|
||||
|
||||
// Resize if the current size is smaller than the new min size - happens when the window is resized smaller
|
||||
if (panelHandleRef.current.getSize() < minSizePct) {
|
||||
const currentSize = panelHandleRef.current.getSize();
|
||||
|
||||
// If currentSize is 0, the panel is collapsed, so we don't want to resize it
|
||||
// If it's not 0, but less than the minSize, resize it
|
||||
if (currentSize && currentSize < minSizePct) {
|
||||
panelHandleRef.current.resize(minSizePct);
|
||||
}
|
||||
});
|
||||
@ -134,6 +137,14 @@ export const usePanel = (arg: UsePanelOptions): UsePanelReturn => {
|
||||
resizeObserver.observe(panelGroupElement);
|
||||
panelGroupHandleElements.forEach((el) => resizeObserver.observe(el));
|
||||
|
||||
// Resize the panel to the min size once on startup
|
||||
const minSizePct = getSizeAsPercentage(
|
||||
arg.minSize,
|
||||
arg.panelGroupRef,
|
||||
arg.panelGroupDirection
|
||||
);
|
||||
panelHandleRef.current?.resize(minSizePct);
|
||||
|
||||
return () => {
|
||||
resizeObserver.disconnect();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user