Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertFileSrc } from "@/platform/tauri-core";
import { useMemo, useState, type ReactNode } from "react";
import { useLayoutEffect, useMemo, useState, type ReactNode } from "react";
import { useFileSystemStore } from "@/features/file-system/stores/file-system.store";
import { useRecentFoldersStore } from "@/features/file-system/stores/recent-folders.store";
import { useTranslation } from "@/i18n/locale-provider";
Expand Down Expand Up @@ -27,6 +27,7 @@ import {
DropdownMenuTrigger,
} from "@/ui/dropdown";
import { Button } from "@/ui/button";
import { bindScrollContainerWheel } from "@/ui/scroll-container-wheel";
import { cn } from "@/utils/cn";

interface TitleProjectMenuProps {
Expand Down Expand Up @@ -115,11 +116,17 @@ export function TitleProjectMenu({ onOpenProjectPicker }: TitleProjectMenuProps)
const isSwitchingProject = useFileSystemStore((state) => state.isSwitchingProject);
const projectLabel = activeProject?.name ?? t("projectOpen.title");
const [isOpen, setIsOpen] = useState(false);
const [menuNode, setMenuNode] = useState<HTMLDivElement | null>(null);
const projects = useMemo(
() => getTitleProjectMenuProjects(projectTabs, recentFolders),
[projectTabs, recentFolders],
);

useLayoutEffect(() => {
if (!menuNode) return;
return bindScrollContainerWheel(menuNode);
}, [menuNode]);

const closeAndRun = (action: () => void) => {
setIsOpen(false);
action();
Expand Down Expand Up @@ -154,6 +161,7 @@ export function TitleProjectMenu({ onOpenProjectPicker }: TitleProjectMenuProps)
</DropdownMenuTrigger>

<DropdownMenuContent
ref={setMenuNode}
align="start"
side="bottom"
className="max-h-[min(32.5rem,calc(100vh-3rem))] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-md p-1.5"
Expand Down
4 changes: 2 additions & 2 deletions windows/tauri/src/ui/scroll-container-wheel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const DOM_DELTA_LINE = 1;
const DOM_DELTA_PAGE = 2;

// Chromium/WebView2 can latch wheel events onto overflow:hidden tree rows
// instead of the sidebar scroller. Apply the delta to the real container.
// Chromium/WebView2 can latch wheel events onto overflow:hidden descendants
// instead of the intended scroller. Apply the delta to the real container.

export const SIDEBAR_SCROLL_CONTAINER_SELECTOR =
"[data-slot='scroll-area-viewport'], [data-scroll-container], .file-tree-container";
Expand Down
Loading