Skip to content

fix(onFileOpen Callback): Add onFileOpen Callback for Navigation Pane folder open event #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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