Skip to content

Commit 4ade0d7

Browse files
committed
fix(files): attach wheel listener before paint and guard SVG src
1 parent bc99c45 commit 4ade0d7

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,12 +1081,14 @@ function SvgPreview({ content }: { content: string }) {
10811081

10821082
return (
10831083
<ZoomablePreview className='h-full' contentClassName='h-full w-full'>
1084-
<img
1085-
src={blobUrl}
1086-
alt='SVG preview'
1087-
className='max-h-full max-w-full select-none object-contain'
1088-
draggable={false}
1089-
/>
1084+
{blobUrl && (
1085+
<img
1086+
src={blobUrl}
1087+
alt='SVG preview'
1088+
className='max-h-full max-w-full select-none object-contain'
1089+
draggable={false}
1090+
/>
1091+
)}
10901092
</ZoomablePreview>
10911093
)
10921094
}

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/zoomable-preview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import type { MouseEvent, ReactNode } from 'react'
4-
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
4+
import { useCallback, useLayoutEffect, useRef, useState } from 'react'
55
import { cn } from '@/lib/core/utils/cn'
66
import { PreviewToolbar } from './preview-toolbar'
77
import { bindPreviewWheelZoom } from './preview-wheel-zoom'
@@ -134,7 +134,7 @@ export function ZoomablePreview({
134134
applyZoom(clampZoom(zoom / ZOOM_BUTTON_FACTOR))
135135
}
136136

137-
useEffect(() => {
137+
useLayoutEffect(() => {
138138
const viewport = viewportRef.current
139139
if (!viewport) return
140140

0 commit comments

Comments
 (0)