From c82965067c5ce868926ac75650a51d5950dd7cce Mon Sep 17 00:00:00 2001 From: Bergasha Date: Thu, 27 Aug 2026 14:17:05 +1000 Subject: [PATCH] Floor containerContentScale above zero logicalWidth/viewportHeight can go non-positive for a narrow container on a heavily zoomed-out board, where outerCardInset (which grows as canvasScale shrinks) can exceed the container's own un-inset size. That non-positive scale then feeds into a division (Infinity/NaN into --board-canvas-ui-scale) and is used as zoom directly (invalid or collapsed content) - flooring it well above zero avoids both. --- .../src/components/board/sections/grid/section-grid.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/nextjs/src/components/board/sections/grid/section-grid.tsx b/apps/nextjs/src/components/board/sections/grid/section-grid.tsx index d08c260d0..a7401f0e9 100644 --- a/apps/nextjs/src/components/board/sections/grid/section-grid.tsx +++ b/apps/nextjs/src/components/board/sections/grid/section-grid.tsx @@ -172,9 +172,14 @@ export const SectionGrid = ({ // by, so a non-uniform stretch can never be captured by it correctly. That means one axis can // be left with a small amount of unfilled slack when width/height need different ratios to // exactly fit - centered below so it's even on both sides rather than left-aligned. + // logicalWidth/viewportHeight can go non-positive for a narrow (e.g. single-column) container + // on a heavily zoomed-out board, where outerCardInset (which grows as canvasScale shrinks) can + // exceed the container's own un-inset size. Floor the scale well above 0 so it can never reach + // zero or negative - combinedUiScale divides by this value, and this value is also used as + // zoom directly, both of which break (Infinity/NaN, or invalid/collapsed content) otherwise. const containerContentScale = section.kind === "container" && fullGridWidth > 0 && fullViewportHeight > 0 - ? Math.min(logicalWidth / fullGridWidth, viewportHeight / fullViewportHeight, 1) + ? Math.max(0.01, Math.min(logicalWidth / fullGridWidth, viewportHeight / fullViewportHeight, 1)) : 1; // Compute the combined value in JS rather than a CSS calc() referencing the existing // --board-canvas-ui-scale: custom properties declared on the *same* element don't have a