11import RcTree from "rc-tree" ;
22import { DataNode , Key } from "rc-tree/lib/interface" ;
33import React , { useEffect , useState } from "react" ;
4- import { Element , scroller } from "react-scroll" ;
4+ import { Element } from "react-scroll" ;
55
66import EllipticLoader from "../EllipticLoader" ;
77import { PathType , useWorkbenchDB } from "../../contexts/dbContext" ;
88
99import SwitcherIcon from "./SwitcherIcon" ;
10- import { scrollToDomElement } from "../../utils/dom" ;
1110
1211import "./FileTree.css" ;
1312
@@ -26,29 +25,18 @@ const FileTree = (props: React.HTMLProps<HTMLDivElement>) => {
2625
2726 useEffect ( ( ) => {
2827 setExpandedKeys ( ( keys ) => {
29- console . log (
30- "Adding" ,
31- currentPath . substring ( 0 , currentPath . lastIndexOf ( "/" ) ) ,
32- [ ...keys , currentPath . substring ( 0 , currentPath . lastIndexOf ( "/" ) ) ]
33- ) ;
3428 return [ ...keys , currentPath . substring ( 0 , currentPath . lastIndexOf ( "/" ) ) ] ;
3529 } ) ;
3630 if ( currentPath . length ) {
3731 setTimeout ( ( ) => {
3832 const targetNode = document . getElementsByName ( currentPath ) [ 0 ] ;
3933 if ( targetNode ) {
40- // scrollToDomElement(targetNode, { yOffset: -50 });
4134 targetNode . scrollIntoView ( {
4235 behavior : "smooth" ,
4336 block : "start" ,
4437 inline : "start" ,
4538 } ) ;
4639 }
47- // scroller.scrollTo(currentPath, {
48- // duration: 0,
49- // delay: 30,
50- // smooth: "easeInOutQuart",
51- // });
5240 } , 500 ) ;
5341 }
5442 } , [ currentPath ] ) ;
@@ -64,13 +52,8 @@ const FileTree = (props: React.HTMLProps<HTMLDivElement>) => {
6452 function wrapNode ( node : DataNode ) {
6553 const key = String ( node . key ) ;
6654 node . title = (
67- < Element
68- key = { key }
69- name = { key }
70- className = "filetree-node-wrapper"
71- >
55+ < Element key = { key } name = { key } className = "filetree-node-wrapper" >
7256 < span > { String ( node . title ) } </ span >
73- { /* <span id={key}>{String(node.title)}</span> */ }
7457 </ Element >
7558 ) ;
7659 node . children ?. forEach ( wrapNode ) ;
@@ -98,12 +81,6 @@ const FileTree = (props: React.HTMLProps<HTMLDivElement>) => {
9881 ) ;
9982 }
10083
101- // console.log("Filetree", {
102- // currentPath,
103- // selectedKeys: [currentPath],
104- // defaultExpanded: [currentPath.substring(0, currentPath.lastIndexOf("/"))],
105- // });
106-
10784 return (
10885 < div className = "file-tree-container" { ...props } >
10986 < RcTree
@@ -118,10 +95,8 @@ const FileTree = (props: React.HTMLProps<HTMLDivElement>) => {
11895 const newKeys = keys . filter (
11996 ( key ) => ! String ( key ) . startsWith ( String ( node . key ) )
12097 ) ;
121- console . log ( "On collapse keys" , newKeys ) ;
12298 setExpandedKeys ( newKeys ) ;
12399 } else {
124- console . log ( "New expanded" , keys ) ;
125100 setExpandedKeys ( keys ) ;
126101 }
127102 } }
0 commit comments