Fix DraggableGridLayout initial height collapse due to nullish coalescing bug

availableWidth starts at 0 (not null/undefined) before ResizeObserver fires.
The ?? operator passes 0 through instead of falling back to window.innerWidth,
making cellHeight negative and causing react-grid-layout to render a ~10px
container. The overflow-x-hidden div then becomes an implicit scroll container,
producing the 'cards squeezed in a small rectangle' symptom.

Changing ?? to || makes 0 trigger the window.innerWidth fallback, giving a
reasonable initial rowHeight until the real container width is measured.

https://claude.ai/code/session_01H1sqbcFmtwwsdNTJcJHJWd
This commit is contained in:
Claude 2026-03-15 10:15:52 +00:00
parent a0ca322129
commit 84f3b16461
No known key found for this signature in database

View File

@ -359,7 +359,7 @@ export default function DraggableGridLayout({
// subtract container margin, 1 camera takes up at least 4 rows
// account for additional margin on bottom of each row
return (
((availableWidth ?? window.innerWidth) - 2 * marginValue) /
((availableWidth || window.innerWidth) - 2 * marginValue) /
12 /
aspectRatio -
marginValue +
@ -712,7 +712,7 @@ export default function DraggableGridLayout({
/>
<Responsive
className="grid-layout"
width={availableWidth ?? window.innerWidth}
width={availableWidth || window.innerWidth}
layouts={{
lg: currentGridLayout,
md: currentGridLayout,