Skip to content

Commit 014d85c

Browse files
Merge pull request #170 from Saifullah-dev/168-onfileopen-event-not-triggered-when-opening-a-folder-from-the-left-sidebar
fix(onFileOpen Callback): Add onFileOpen Callback for Navigation Pane folder open event
2 parents 8cd0d2a + d346be5 commit 014d85c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

frontend/src/FileManager/FileManager.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const FileManager = ({
7777
className="files-container"
7878
>
7979
<div className="navigation-pane" style={{ width: colSizes.col1 + "%" }}>
80-
<NavigationPane />
80+
<NavigationPane onFileOpen={onFileOpen} />
8181
<div
8282
className={`sidebar-resize ${isDragging ? "sidebar-dragging" : ""}`}
8383
onMouseDown={handleMouseDown}

frontend/src/FileManager/NavigationPane/FolderTree.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import { FaRegFolder, FaRegFolderOpen } from "react-icons/fa";
44
import { MdKeyboardArrowRight } from "react-icons/md";
55
import { useFileNavigation } from "../../contexts/FileNavigationContext";
66

7-
const FolderTree = ({ folder }) => {
7+
const FolderTree = ({ folder, onFileOpen }) => {
88
const [isOpen, setIsOpen] = useState(false);
99
const [isActive, setIsActive] = useState(false);
1010
const { currentPath, setCurrentPath } = useFileNavigation();
1111

1212
const handleFolderSwitch = () => {
1313
setIsActive(true);
14+
onFileOpen(folder);
1415
setCurrentPath(folder.path);
1516
};
1617

@@ -61,7 +62,7 @@ const FolderTree = ({ folder }) => {
6162
<Collapse open={isOpen}>
6263
<div className="folder-collapsible">
6364
{folder.subDirectories.map((item, index) => (
64-
<FolderTree key={index} folder={item} />
65+
<FolderTree key={index} folder={item} onFileOpen={onFileOpen} />
6566
))}
6667
</div>
6768
</Collapse>

frontend/src/FileManager/NavigationPane/NavigationPane.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getParentPath } from "../../utils/getParentPath";
44
import { useFiles } from "../../contexts/FilesContext";
55
import "./NavigationPane.scss";
66

7-
const NavigationPane = () => {
7+
const NavigationPane = ({ onFileOpen }) => {
88
const [foldersTree, setFoldersTree] = useState([]);
99
const { files } = useFiles();
1010

@@ -36,7 +36,7 @@ const NavigationPane = () => {
3636
{foldersTree?.length > 0 ? (
3737
<>
3838
{foldersTree?.map((folder, index) => {
39-
return <FolderTree key={index} folder={folder} />;
39+
return <FolderTree key={index} folder={folder} onFileOpen={onFileOpen} />;
4040
})}
4141
</>
4242
) : (

0 commit comments

Comments
 (0)