Skip to content

Commit 63f4ec4

Browse files
author
Dominique Chuo
committed
fixes build
1 parent 963a5b6 commit 63f4ec4

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/components/InlineCodeBlock/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ export default function InlineCodeBlock({
1717
language = 'sql',
1818
forceViewer = false
1919
}: InlineCodeBlockProps) {
20-
const [isMobile, setIsMobile] = useState(false);
20+
const [isMobile, setIsMobile] = useState(() => {
21+
// Check if we're on the server (SSR)
22+
if (typeof window === 'undefined') {
23+
return false; // Default to desktop during SSR
24+
}
25+
// Initial client-side check
26+
const hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
27+
const isSmallScreen = window.innerWidth <= 768;
28+
return hasTouch || isSmallScreen;
29+
});
2130

2231
useEffect(() => {
2332
// Check if device is mobile on mount and window resize

src/components/InlineEditor/index.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export default function InlineEditor({
6262
const minHeight = (minLines * lineHeight) + extraPadding;
6363

6464
// Get viewport height and calculate max allowed height (e.g., 80% of viewport)
65-
const viewportHeight = window.innerHeight;
65+
// Use a default during SSR
66+
const viewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800;
6667
const maxHeight = Math.floor(viewportHeight * 0.8);
6768

6869
// Calculate height but limit to max screen height
@@ -73,7 +74,20 @@ export default function InlineEditor({
7374
return calculatedHeight;
7475
}, []);
7576

76-
const [editorHeight, setEditorHeight] = useState(() => calculateHeight(initialQuery));
77+
const [editorHeight, setEditorHeight] = useState(() => {
78+
// During SSR, use a default height calculation
79+
const lines = initialQuery.split('\n').length;
80+
const lineHeight = 24;
81+
const extraPadding = 20;
82+
const minLines = 3;
83+
const minHeight = (minLines * lineHeight) + extraPadding;
84+
const defaultMaxHeight = 640; // 80% of 800px default
85+
86+
return Math.min(
87+
Math.max((lines * lineHeight) + extraPadding, minHeight),
88+
defaultMaxHeight
89+
);
90+
});
7791

7892
const updateHeightDirectly = useCallback((newHeight: number) => {
7993
if (containerRef.current) {
@@ -102,6 +116,11 @@ export default function InlineEditor({
102116

103117
// Handle window resize to recalculate max height
104118
useEffect(() => {
119+
// Only add resize listener on client side
120+
if (typeof window === 'undefined') {
121+
return;
122+
}
123+
105124
const handleResize = () => {
106125
const newHeight = calculateHeight(query);
107126
updateHeightDirectly(newHeight);

0 commit comments

Comments
 (0)