From d9b54c63c069c09fbc5035239f941addf2543330 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 13 Apr 2026 18:05:20 -0400 Subject: [PATCH] fix: Guard against undefined boundsRef in MediaDimension (#12026) Co-authored-by: Claude Opus 4.6 --- app/editor/components/MediaDimension.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/editor/components/MediaDimension.tsx b/app/editor/components/MediaDimension.tsx index b53afa9a13..706f85907d 100644 --- a/app/editor/components/MediaDimension.tsx +++ b/app/editor/components/MediaDimension.tsx @@ -68,7 +68,10 @@ export function MediaDimension() { const isOutsideBounds = useCallback( (type: "width" | "height", value: number) => { - const bounds = boundsRef.current!; + const bounds = boundsRef.current; + if (!bounds) { + return false; + } return value < bounds[type].min || value > bounds[type].max; }, [] @@ -128,12 +131,12 @@ export function MediaDimension() { localWidthAsNumber && isOutsideBounds("width", localWidthAsNumber)); // check width bounds here since 'onChange' error checker is debounced. - if (isUnchanged || isError) { + if (isUnchanged || isError || !boundsRef.current) { reset(); return; } - const maxWidth = boundsRef.current!.width.max; + const maxWidth = boundsRef.current.width.max; // For images resized to the full width of the editor, natural width will be shown in the toolbar. // So, we constrain it here for computing aspect ratio. const constrainedWidth = Math.min(width, maxWidth);