fix(FN-949): prevent bounce-back on Projects nav and show in mobile overflow
clearCurrentProject was triggering auto-reselect in useCurrentProject, making the Projects button ineffective for single-project users. Added explicit-clear flag to suppress auto-select. Also changed mobile overflow menu to show Projects for single-project users (was gated to 2+ projects). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
||||
import { Settings, Pause, Play, Square, LayoutGrid, List, Terminal, Lightbulb, Search, X, Activity, MoreHorizontal, Clock, Folder, History, GitBranch, Workflow, Bot, ChevronLeft, Target, Building2, ChevronRight, FileCode, Loader2, Grid3X3 } from "lucide-react";
|
||||
import { Settings, Pause, Play, Square, LayoutGrid, List, Terminal, Lightbulb, Search, X, Activity, MoreHorizontal, Clock, Folder, History, GitBranch, Workflow, Bot, ChevronLeft, Target, ChevronRight, FileCode, Loader2, Grid3X3 } from "lucide-react";
|
||||
import type { ProjectInfo } from "../api";
|
||||
import { fetchScripts } from "../api";
|
||||
import { ProjectSelector } from "./ProjectSelector";
|
||||
@@ -573,16 +573,16 @@ export function Header({
|
||||
role="menu"
|
||||
aria-label="Additional header actions"
|
||||
>
|
||||
{/* Switch Project - in overflow on mobile */}
|
||||
{projects.length > 1 && onViewAllProjects && (
|
||||
{/* Projects - in overflow on mobile */}
|
||||
{projects.length >= 1 && onViewAllProjects && (
|
||||
<button
|
||||
className="mobile-overflow-item"
|
||||
onClick={() => handleOverflowAction(onViewAllProjects)}
|
||||
role="menuitem"
|
||||
data-testid="overflow-project-selector-btn"
|
||||
>
|
||||
<Building2 size={16} />
|
||||
<span>{currentProject ? currentProject.name : "Switch Project"}</span>
|
||||
<Grid3X3 size={16} />
|
||||
<span>Projects</span>
|
||||
</button>
|
||||
)}
|
||||
{/* Files - in overflow on mobile */}
|
||||
|
||||
@@ -625,8 +625,7 @@ describe("Header", () => {
|
||||
fireEvent.click(screen.getByTitle("More header actions"));
|
||||
const btn = screen.getByTestId("overflow-project-selector-btn");
|
||||
expect(btn).toBeDefined();
|
||||
// Should show the current project name
|
||||
expect(btn.textContent).toContain("Project One");
|
||||
expect(btn.textContent).toContain("Projects");
|
||||
});
|
||||
|
||||
it("overflow project selector calls onViewAllProjects when clicked", () => {
|
||||
@@ -679,7 +678,7 @@ describe("Header", () => {
|
||||
expect(projectSvg!.innerHTML).not.toBe(filesSvg!.innerHTML);
|
||||
});
|
||||
|
||||
it("does not show switch project in overflow menu with single project", () => {
|
||||
it("shows projects in overflow menu with single project", () => {
|
||||
const projects = [
|
||||
{ id: "proj_1", name: "Project One", path: "/path/1", status: "active" as const, isolationMode: "in-process" as const, createdAt: "", updatedAt: "" },
|
||||
];
|
||||
@@ -692,7 +691,7 @@ describe("Header", () => {
|
||||
/>
|
||||
);
|
||||
fireEvent.click(screen.getByTitle("More header actions"));
|
||||
expect(screen.queryByTestId("overflow-project-selector-btn")).toBeNull();
|
||||
expect(screen.queryByTestId("overflow-project-selector-btn")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("missions overflow menu item calls onOpenMissions when clicked", () => {
|
||||
|
||||
Reference in New Issue
Block a user