Skip to content

Commit e04c7bc

Browse files
committed
Code rabbit fixes
1 parent 477db49 commit e04c7bc

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

apps/webapp/app/components/primitives/Resizable.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,20 @@ function isValidSnapshot(value: unknown): boolean {
7070
if (it.type !== "panel") continue;
7171
const cv = it.currentValue as Record<string, unknown> | null;
7272
if (!cv || typeof cv !== "object" || cv.type !== "pixel") return false;
73-
// value must be numeric (number or numeric string) so prepareSnapshot's
74-
// `new Big(value)` rehydration can't throw on us.
75-
if (typeof cv.value !== "string" && typeof cv.value !== "number") return false;
73+
// value must parse as a finite number so prepareSnapshot's
74+
// `new Big(value)` rehydration can't throw — guards against strings
75+
// like "50%" or "" that satisfy typeof but break Big.
76+
if (!isFiniteNumeric(cv.value)) return false;
7677
}
7778
return true;
7879
}
7980

81+
function isFiniteNumeric(v: unknown): boolean {
82+
if (typeof v === "number") return Number.isFinite(v);
83+
if (typeof v === "string" && v.trim() !== "") return Number.isFinite(Number(v));
84+
return false;
85+
}
86+
8087
const ResizablePanel = Panel;
8188

8289
const ResizableHandle = ({

0 commit comments

Comments
 (0)