fix(ui): close sidebar on mobile when command palette opens

When searching via the command palette on mobile, the left sidebar
now automatically closes so search results are visible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dotta
2026-03-05 18:23:36 -06:00
parent 222e0624a8
commit 0cdc9547d9

View File

@@ -3,6 +3,7 @@ import { useNavigate } from "@/lib/router";
import { useQuery } from "@tanstack/react-query";
import { useCompany } from "../context/CompanyContext";
import { useDialog } from "../context/DialogContext";
import { useSidebar } from "../context/SidebarContext";
import { issuesApi } from "../api/issues";
import { agentsApi } from "../api/agents";
import { projectsApi } from "../api/projects";
@@ -37,6 +38,7 @@ export function CommandPalette() {
const navigate = useNavigate();
const { selectedCompanyId } = useCompany();
const { openNewIssue, openNewAgent } = useDialog();
const { isMobile, setSidebarOpen } = useSidebar();
const searchQuery = query.trim();
useEffect(() => {
@@ -44,11 +46,12 @@ export function CommandPalette() {
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
setOpen(true);
if (isMobile) setSidebarOpen(false);
}
}
document.addEventListener("keydown", handleKeyDown);
return () => document.removeEventListener("keydown", handleKeyDown);
}, []);
}, [isMobile, setSidebarOpen]);
useEffect(() => {
if (!open) setQuery("");
@@ -94,7 +97,10 @@ export function CommandPalette() {
);
return (
<CommandDialog open={open} onOpenChange={setOpen}>
<CommandDialog open={open} onOpenChange={(v) => {
setOpen(v);
if (v && isMobile) setSidebarOpen(false);
}}>
<CommandInput
placeholder="Search issues, agents, projects..."
value={query}