Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix resize editor selection bug

Tomas Valenta431633de8c8f
diff --git a/components/Editor/index.tsx b/components/Editor/index.tsx
index f1be779c8..c031ba7b9 100644
--- a/components/Editor/index.tsx
+++ b/components/Editor/index.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useState } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import { projects } from '@prisma/client'
import Splitter, { GutterTheme } from '@devbookhq/splitter'
import { useLocalStorage } from 'usehooks-ts'
@@ -15,6 +15,8 @@ export interface Props {
function Editor({ project }: Props) {
const store = useStateStore()
+ const ref = useRef<HTMLDivElement | null>(null)
+
// TODO: Handle editor state differently so we don't rerender this component on each editor edit.
const routes = store.use.routes()
@@ -40,8 +42,17 @@ function Editor({ project }: Props) {
const [sizes, setSizes] = useLocalStorage('project-board-splitter-sizes', [60, 40])
const handleResize = useCallback((_: number, newSizes: number[]) => {
setSizes(newSizes)
+ if (ref.current) {
+ ref.current.style.pointerEvents = 'auto'
+ }
}, [setSizes])
+ const onResizeStart = useCallback(() => {
+ if (ref.current) {
+ ref.current.style.pointerEvents = 'none'
+ }
+ }, [])
+
return (
<div className="
flex
@@ -55,10 +66,13 @@ function Editor({ project }: Props) {
initialSizes={sizes}
classes={['flex', 'flex']}
onResizeFinished={handleResize}
+ onResizeStarted={onResizeStart}
gutterClassName='bg-slate-200'
draggerClassName='bg-slate-400'
>
- <div className="
+ <div
+ ref={ref}
+ className="
flex
flex-col
flex-1