Skip to content

Commit 5d1aa22

Browse files
authored
fix(files): attach wheel listener before paint and guard SVG src (#4744)
* fix(files): attach wheel listener before paint and guard SVG src * chore(deps): upgrade turbo to 2.9.14
1 parent e07b1ff commit 5d1aa22

4 files changed

Lines changed: 20 additions & 17 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

bun.lock

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"husky": "9.1.7",
6565
"json-schema-to-typescript": "15.0.4",
6666
"lint-staged": "16.0.0",
67-
"turbo": "2.9.12",
67+
"turbo": "2.9.14",
6868
"yaml": "^2.8.1"
6969
},
7070
"lint-staged": {

0 commit comments

Comments
 (0)