Skip to content

Commit

Permalink
fix: expand explorer if currentPath is a dir
Browse files Browse the repository at this point in the history
The only way for currentPath to be a dir is if the user is navigating with the mouse on the browser
using the explorer or if the user clicked on a breadcrumb. We expand explorer to allow the user to
continue navigating using the mouse.
  • Loading branch information
wallpants committed Oct 15, 2023
1 parent 94c64ad commit b7c94be
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/src/web/explorer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useState } from "react";
import { useContext, useEffect, useState } from "react";
import { websocketContext } from "../provider/context.ts";
import { cn } from "../utils.ts";
import { EntryComponent } from "./entry.tsx";
Expand All @@ -9,6 +9,11 @@ export const Explorer = () => {
const { currentPath, isSingleFile } = useContext(websocketContext);
const [isExpanded, setIsExpanded] = useState(false);

useEffect(() => {
const isDir = Boolean(currentPath?.endsWith("/"));
if (isDir) setIsExpanded(true);
}, [currentPath]);

return (
<div
className={cn(
Expand Down

0 comments on commit b7c94be

Please sign in to comment.