Skip to content

Commit 9a9131a

Browse files
committed
improvement(zoom-prevention): moved downstream
1 parent ae397c3 commit 9a9131a

File tree

13 files changed

+62
-225
lines changed

13 files changed

+62
-225
lines changed

apps/sim/app/_shell/zoom-prevention.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

apps/sim/app/layout.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { HydrationErrorHandler } from '@/app/_shell/hydration-error-handler'
1111
import { QueryProvider } from '@/app/_shell/providers/query-provider'
1212
import { SessionProvider } from '@/app/_shell/providers/session-provider'
1313
import { ThemeProvider } from '@/app/_shell/providers/theme-provider'
14-
import { ZoomPrevention } from '@/app/_shell/zoom-prevention'
1514
import { season } from '@/app/_styles/fonts/season/season'
1615

1716
export const viewport: Viewport = {
@@ -190,10 +189,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
190189
<ThemeProvider>
191190
<QueryProvider>
192191
<SessionProvider>
193-
<BrandedLayout>
194-
<ZoomPrevention />
195-
{children}
196-
</BrandedLayout>
192+
<BrandedLayout>{children}</BrandedLayout>
197193
</SessionProvider>
198194
</QueryProvider>
199195
</ThemeProvider>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/chat.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ import {
2929
OutputSelect,
3030
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components'
3131
import { useChatFileUpload } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/chat/hooks'
32-
import { useScrollManagement } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
32+
import {
33+
usePreventZoom,
34+
useScrollManagement,
35+
} from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
3336
import {
3437
useFloatBoundarySync,
3538
useFloatDrag,
@@ -225,6 +228,7 @@ export function Chat() {
225228
const inputRef = useRef<HTMLInputElement>(null)
226229
const timeoutRef = useRef<NodeJS.Timeout | null>(null)
227230
const abortControllerRef = useRef<AbortController | null>(null)
231+
const preventZoomRef = usePreventZoom()
228232

229233
// File upload hook
230234
const {
@@ -784,6 +788,7 @@ export function Chat() {
784788

785789
return (
786790
<div
791+
ref={preventZoomRef}
787792
className='fixed z-30 flex flex-col overflow-hidden rounded-[6px] border border-[var(--border)] bg-[var(--surface-1)] px-[10px] pt-[2px] pb-[8px]'
788793
style={{
789794
left: `${actualPosition.x}px`,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/command-list/command-list.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Button } from '@/components/emcn'
88
import { AgentIcon } from '@/components/icons'
99
import { cn } from '@/lib/core/utils/cn'
1010
import { createLogger } from '@/lib/logs/console/logger'
11+
import { usePreventZoom } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
1112
import { useSearchModalStore } from '@/stores/search-modal/store'
1213

1314
const logger = createLogger('WorkflowCommandList')
@@ -58,6 +59,7 @@ export function CommandList() {
5859
const params = useParams()
5960
const router = useRouter()
6061
const { open: openSearchModal } = useSearchModalStore()
62+
const preventZoomRef = usePreventZoom()
6163

6264
const workspaceId = params.workspaceId as string | undefined
6365

@@ -171,6 +173,7 @@ export function CommandList() {
171173

172174
return (
173175
<div
176+
ref={preventZoomRef}
174177
className={cn(
175178
'pointer-events-none absolute inset-0 mb-[50px] flex items-center justify-center'
176179
)}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/cursors/cursors.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { memo, useMemo } from 'react'
44
import { useViewport } from 'reactflow'
55
import { useSession } from '@/lib/auth/auth-client'
6+
import { usePreventZoom } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
67
import { getUserColor } from '@/app/workspace/[workspaceId]/w/utils/get-user-color'
78
import { useSocket } from '@/app/workspace/providers/socket-provider'
89

@@ -23,6 +24,7 @@ const CursorsComponent = () => {
2324
const viewport = useViewport()
2425
const session = useSession()
2526
const currentUserId = session.data?.user?.id
27+
const preventZoomRef = usePreventZoom()
2628

2729
const cursors = useMemo<CursorRenderData[]>(() => {
2830
return presenceUsers
@@ -41,7 +43,7 @@ const CursorsComponent = () => {
4143
}
4244

4345
return (
44-
<div className='pointer-events-none absolute inset-0 z-30 select-none'>
46+
<div ref={preventZoomRef} className='pointer-events-none absolute inset-0 z-30 select-none'>
4547
{cursors.map(({ id, name, cursor, color }) => {
4648
const x = cursor.x * viewport.zoom + viewport.x
4749
const y = cursor.y * viewport.zoom + viewport.y

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/diff-controls/diff-controls.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import clsx from 'clsx'
33
import { Eye, EyeOff } from 'lucide-react'
44
import { Button } from '@/components/emcn'
55
import { createLogger } from '@/lib/logs/console/logger'
6+
import { usePreventZoom } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
67
import { useCopilotStore } from '@/stores/panel/copilot/store'
78
import { useTerminalStore } from '@/stores/terminal'
89
import { useWorkflowDiffStore } from '@/stores/workflow-diff'
@@ -308,13 +309,16 @@ export const DiffControls = memo(function DiffControls() {
308309
})
309310
}, [clearPreviewYaml, updatePreviewToolCallState, rejectChanges])
310311

312+
const preventZoomRef = usePreventZoom()
313+
311314
// Don't show anything if no diff is available or diff is not ready
312315
if (!hasActiveDiff || !isDiffReady) {
313316
return null
314317
}
315318

316319
return (
317320
<div
321+
ref={preventZoomRef}
318322
className={clsx(
319323
'-translate-x-1/2 fixed left-1/2 z-30',
320324
!isTerminalResizing && 'transition-[bottom] duration-100 ease-out'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/error/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Component, type ReactNode, useEffect } from 'react'
44
import { createLogger } from '@/lib/logs/console/logger'
55
import { Panel } from '@/app/workspace/[workspaceId]/w/[workflowId]/components'
6+
import { usePreventZoom } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
67
import { Sidebar } from '@/app/workspace/[workspaceId]/w/components/sidebar/sidebar'
78

89
const logger = createLogger('ErrorBoundary')
@@ -23,12 +24,13 @@ export function ErrorUI({
2324
onReset,
2425
fullScreen = false,
2526
}: ErrorUIProps) {
27+
const preventZoomRef = usePreventZoom()
2628
const containerClass = fullScreen
2729
? 'flex flex-col w-full h-screen bg-[var(--surface-1)]'
2830
: 'flex flex-col w-full h-full bg-[var(--surface-1)]'
2931

3032
return (
31-
<div className={containerClass}>
33+
<div ref={preventZoomRef} className={containerClass}>
3234
{/* Sidebar */}
3335
<Sidebar />
3436

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export { DiffControls } from './diff-controls/diff-controls'
44
export { ErrorBoundary } from './error/index'
55
export { Notifications } from './notifications/notifications'
66
export { Panel } from './panel/panel'
7-
export { SkeletonLoading } from './skeleton-loading/skeleton-loading'
87
export { SubflowNodeComponent } from './subflows/subflow-node'
98
export { Terminal } from './terminal/terminal'
109
export { WandPromptBar } from './wand-prompt-bar/wand-prompt-bar'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/notifications/notifications.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Button } from '@/components/emcn'
66
import { createLogger } from '@/lib/logs/console/logger'
77
import { useRegisterGlobalCommands } from '@/app/workspace/[workspaceId]/providers/global-commands-provider'
88
import { createCommands } from '@/app/workspace/[workspaceId]/utils/commands-utils'
9+
import { usePreventZoom } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
910
import {
1011
type NotificationAction,
1112
openCopilotWithMessage,
@@ -93,12 +94,15 @@ export const Notifications = memo(function Notifications() {
9394
])
9495
)
9596

97+
const preventZoomRef = usePreventZoom()
98+
9699
if (visibleNotifications.length === 0) {
97100
return null
98101
}
99102

100103
return (
101104
<div
105+
ref={preventZoomRef}
102106
className={clsx(
103107
'fixed right-[calc(var(--panel-width)+16px)] bottom-[calc(var(--terminal-height)+16px)] z-30 flex flex-col items-end',
104108
!isTerminalResizing && 'transition-[bottom] duration-100 ease-out'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/skeleton-loading/skeleton-loading.tsx

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)