diff --git a/web/src/containers/Drive/index.tsx b/web/src/containers/Drive/index.tsx index 8382831..854cb9b 100644 --- a/web/src/containers/Drive/index.tsx +++ b/web/src/containers/Drive/index.tsx @@ -90,7 +90,11 @@ const Drive = () => { return ( - +
({ const drawerWidth = 240 type Props = { + selectedFilePath: string directoryData: TreeNode | null handleSelect: (node: TreeNode) => void } -const SideBar = ({ directoryData, handleSelect }: Props) => { +const SideBar = ({ selectedFilePath, directoryData, handleSelect }: Props) => { const classes = useStyles() + const defaultExpanded = useMemo(() => { + const splittedPath = selectedFilePath.split('/') + const arr = [''] + let nodeId = '' + splittedPath.forEach((path) => { + if (path !== '') { + nodeId += '/' + path + arr.push(nodeId) + } + }) + return arr + }, [selectedFilePath]) + const renderTree = (nodes: TreeNode) => ( { } defaultExpandIcon={} - defaultExpanded={[directoryData.relativePath]} + defaultExpanded={defaultExpanded} + selected={defaultExpanded.slice(-1)} > {renderTree(directoryData)}