diff --git a/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx b/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx index d8c6dbc6a4..f86cd2873c 100644 --- a/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx +++ b/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx @@ -11,12 +11,10 @@ import { fileDecoration, FileDecorationIcons } from '@remix-ui/file-decorators'; export default function useOnScreen(ref: RefObject) { const [isIntersecting, setIntersecting] = useState(false) - const observer = useMemo(() => new IntersectionObserver( ([entry]) => setIntersecting(entry.isIntersecting) ), [ref]) - useEffect(() => { observer.observe(ref.current) return () => observer.disconnect() @@ -24,7 +22,6 @@ export default function useOnScreen(ref: RefObject) { return isIntersecting } - interface FlatTreeProps { files: { [x: string]: Record }, flatTree: FileType[], @@ -39,7 +36,6 @@ interface FlatTreeProps { moveFile: (dest: string, src: string) => void moveFolder: (dest: string, src: string) => void fileState: fileDecoration[] - } let mouseTimer: any = { @@ -63,17 +59,8 @@ export const FlatTree = (props: FlatTreeProps) => { const [dragSource, setDragSource] = useState() const [isDragging, setIsDragging] = useState(false) const ref = useRef(null) - const [size, setSize] = useState(0) const containerRef = useRef(null) const virtuoso = useRef(null) - const isOnScreen = useOnScreen(containerRef) - - useEffect(() => { - if (isOnScreen) { - setViewPortHeight() - } - }, [isOnScreen]) - const labelClass = (file: FileType) => props.focusEdit.element === file.path @@ -181,25 +168,6 @@ export const FlatTree = (props: FlatTreeProps) => { setShowMouseOverTarget(false) } - - const setViewPortHeight = () => { - const boundingRect = containerRef.current.getBoundingClientRect() - setSize(boundingRect.height - 40) - } - - - useEffect(() => { - window.addEventListener('resize', setViewPortHeight) - return () => { - window.removeEventListener('resize', setViewPortHeight) - } - }, []) - - useEffect(() => { - setViewPortHeight() - }, [containerRef.current]) - - useEffect(() => { if (focusEdit && focusEdit.element) { const index = flatTree.findIndex((item) => item.path === focusEdit.element) @@ -259,12 +227,12 @@ export const FlatTree = (props: FlatTreeProps) => { expandPath={expandPath} >
- {showMouseOverTarget && mouseOverTarget && !isDragging && + { showMouseOverTarget && mouseOverTarget && !isDragging && { minWidth: 'fit-content' } }> - + {mouseOverTarget && mouseOverTarget.path} } Row(index)} /> @@ -294,5 +260,4 @@ export const FlatTree = (props: FlatTreeProps) => {
) - }