From 99d55775aaac3b2caaa4b10d4ed698f6cd7fcb2a Mon Sep 17 00:00:00 2001 From: sabhas Date: Wed, 20 Oct 2021 11:13:36 +0000 Subject: [PATCH] fix: load file when url contains filePath --- web/src/containers/SASjsDrive/sideBar.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/containers/SASjsDrive/sideBar.tsx b/web/src/containers/SASjsDrive/sideBar.tsx index 9f1b754..003fc8d 100644 --- a/web/src/containers/SASjsDrive/sideBar.tsx +++ b/web/src/containers/SASjsDrive/sideBar.tsx @@ -1,5 +1,6 @@ import React, { useState, useEffect } from 'react' import axios from 'axios' +import { useLocation } from 'react-router-dom' import { makeStyles } from '@mui/styles' @@ -36,6 +37,7 @@ const useStyles = makeStyles(() => ({ const drawerWidth = 240 const SideBar = (props: any) => { + const location = useLocation() const baseUrl = window.location.origin const classes = useStyles() @@ -47,6 +49,8 @@ const SideBar = (props: any) => { setDirectoryData(res.data.tree) } }) + const queryParams = new URLSearchParams(location.search) + props.setSelectedFilePath(queryParams.get('filePath')) }, []) const handleSelect = (node: TreeNode) => { @@ -54,7 +58,7 @@ const SideBar = (props: any) => { window.history.pushState( '', '', - `${baseUrl}/#/SASjsDrive?filepath=${node.relativePath}` + `${baseUrl}/#/SASjsDrive?filePath=${node.relativePath}` ) props.setSelectedFilePath(node.relativePath) }