Skip to content

Commit

Permalink
Merge pull request #170 from Saifullah-dev/168-onfileopen-event-not-t…
Browse files Browse the repository at this point in the history
…riggered-when-opening-a-folder-from-the-left-sidebar

fix(onFileOpen Callback): Add onFileOpen Callback for Navigation Pane folder open event
  • Loading branch information
Saifullah-dev authored Feb 18, 2025
2 parents 8cd0d2a + d346be5 commit 014d85c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/src/FileManager/FileManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const FileManager = ({
className="files-container"
>
<div className="navigation-pane" style={{ width: colSizes.col1 + "%" }}>
<NavigationPane />
<NavigationPane onFileOpen={onFileOpen} />
<div
className={`sidebar-resize ${isDragging ? "sidebar-dragging" : ""}`}
onMouseDown={handleMouseDown}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/FileManager/NavigationPane/FolderTree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { FaRegFolder, FaRegFolderOpen } from "react-icons/fa";
import { MdKeyboardArrowRight } from "react-icons/md";
import { useFileNavigation } from "../../contexts/FileNavigationContext";

const FolderTree = ({ folder }) => {
const FolderTree = ({ folder, onFileOpen }) => {
const [isOpen, setIsOpen] = useState(false);
const [isActive, setIsActive] = useState(false);
const { currentPath, setCurrentPath } = useFileNavigation();

const handleFolderSwitch = () => {
setIsActive(true);
onFileOpen(folder);
setCurrentPath(folder.path);
};

Expand Down Expand Up @@ -61,7 +62,7 @@ const FolderTree = ({ folder }) => {
<Collapse open={isOpen}>
<div className="folder-collapsible">
{folder.subDirectories.map((item, index) => (
<FolderTree key={index} folder={item} />
<FolderTree key={index} folder={item} onFileOpen={onFileOpen} />
))}
</div>
</Collapse>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/FileManager/NavigationPane/NavigationPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getParentPath } from "../../utils/getParentPath";
import { useFiles } from "../../contexts/FilesContext";
import "./NavigationPane.scss";

const NavigationPane = () => {
const NavigationPane = ({ onFileOpen }) => {
const [foldersTree, setFoldersTree] = useState([]);
const { files } = useFiles();

Expand Down Expand Up @@ -36,7 +36,7 @@ const NavigationPane = () => {
{foldersTree?.length > 0 ? (
<>
{foldersTree?.map((folder, index) => {
return <FolderTree key={index} folder={folder} />;
return <FolderTree key={index} folder={folder} onFileOpen={onFileOpen} />;
})}
</>
) : (
Expand Down

0 comments on commit 014d85c

Please sign in to comment.