multiple UI fixes/updates (#3422)

This commit is contained in:
Jonathan Dobson
2025-09-12 16:13:05 -04:00
committed by GitHub
parent 012aec0cd5
commit d82eba77b6
5 changed files with 168 additions and 122 deletions

View File

@@ -1,7 +1,7 @@
import { useRef, useState, RefObject } from "react";
import { useMountEffect } from "@/hooks/useMountEffect";
import { cn } from "@/util/utils";
import { useOnChange } from "@/hooks/useOnChange";
import { useMountEffect } from "@/hooks/useMountEffect";
function Handle({
direction,
@@ -341,21 +341,30 @@ function Splitter({
const [isDragging, setIsDragging] = useState(false);
useMountEffect(() => {
if (containerRef.current) {
const newPosition = normalizeUnitsToPercent(
containerRef,
direction,
firstSizingTarget,
firstSizing,
storageKey,
);
// small delay here, to allow for arbitrary layout thrashing to settle;
// otherwise we have to rely on an observer for the container size, and
// resetting whenever the container resizes it likely incorrect behaviour
setTimeout(() => {
if (containerRef.current) {
const newPosition = normalizeUnitsToPercent(
containerRef,
direction,
firstSizingTarget,
firstSizing,
storageKey,
);
setSplitPosition(newPosition);
setSplitPosition(newPosition);
if (storageKey) {
setStoredSizing(firstSizingTarget, storageKey, newPosition.toString());
if (storageKey) {
setStoredSizing(
firstSizingTarget,
storageKey,
newPosition.toString(),
);
}
}
}
}, 100);
});
useOnChange(isDragging, (newValue, oldValue) => {