fix(web): hide mobile sidebar after thread selection or creation (#1293)
Co-authored-by: Murat Aslan <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 file changed
+27
-4
@@ -143,6 +143,7 @@ import {
|
||||
SidebarMenuSubItem,
|
||||
SidebarSeparator,
|
||||
SidebarTrigger,
|
||||
useSidebar,
|
||||
} from "./ui/sidebar";
|
||||
import { useThreadSelectionStore } from "../threadSelectionStore";
|
||||
import { useCommandPaletteStore } from "../commandPaletteStore";
|
||||
@@ -931,6 +932,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
}));
|
||||
const { updateSettings } = useUpdateSettings();
|
||||
const router = useRouter();
|
||||
const { isMobile, setOpenMobile } = useSidebar();
|
||||
const markThreadUnread = useUiStateStore((state) => state.markThreadUnread);
|
||||
const toggleProject = useUiStateStore((state) => state.toggleProject);
|
||||
const toggleThreadSelection = useThreadSelectionStore((state) => state.toggleThread);
|
||||
@@ -1519,12 +1521,15 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
clearSelection();
|
||||
}
|
||||
setSelectionAnchor(scopedThreadKey(threadRef));
|
||||
if (isMobile) {
|
||||
setOpenMobile(false);
|
||||
}
|
||||
void router.navigate({
|
||||
to: "/$environmentId/$threadId",
|
||||
params: buildThreadRouteParams(threadRef),
|
||||
});
|
||||
},
|
||||
[clearSelection, router, setSelectionAnchor],
|
||||
[clearSelection, isMobile, router, setOpenMobile, setSelectionAnchor],
|
||||
);
|
||||
|
||||
const handleThreadClick = useCallback(
|
||||
@@ -1555,12 +1560,23 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
clearSelection();
|
||||
}
|
||||
setSelectionAnchor(threadKey);
|
||||
if (isMobile) {
|
||||
setOpenMobile(false);
|
||||
}
|
||||
void router.navigate({
|
||||
to: "/$environmentId/$threadId",
|
||||
params: buildThreadRouteParams(threadRef),
|
||||
});
|
||||
},
|
||||
[clearSelection, rangeSelectTo, router, setSelectionAnchor, toggleThreadSelection],
|
||||
[
|
||||
clearSelection,
|
||||
isMobile,
|
||||
rangeSelectTo,
|
||||
router,
|
||||
setOpenMobile,
|
||||
setSelectionAnchor,
|
||||
toggleThreadSelection,
|
||||
],
|
||||
);
|
||||
|
||||
const handleMultiSelectContextMenu = useCallback(
|
||||
@@ -1658,6 +1674,9 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
}
|
||||
: null,
|
||||
});
|
||||
if (isMobile) {
|
||||
setOpenMobile(false);
|
||||
}
|
||||
void handleNewThread(scopeProjectRef(member.environmentId, member.id), {
|
||||
...(seedContext.branch !== undefined ? { branch: seedContext.branch } : {}),
|
||||
...(seedContext.worktreePath !== undefined
|
||||
@@ -1666,7 +1685,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
envMode: seedContext.envMode,
|
||||
});
|
||||
},
|
||||
[defaultThreadEnvMode, handleNewThread, router],
|
||||
[defaultThreadEnvMode, handleNewThread, isMobile, router, setOpenMobile],
|
||||
);
|
||||
|
||||
const handleCreateThreadClick = useCallback(
|
||||
@@ -2703,6 +2722,7 @@ export default function Sidebar() {
|
||||
const { updateSettings } = useUpdateSettings();
|
||||
const { handleNewThread } = useNewThreadHandler();
|
||||
const { archiveThread, deleteThread } = useThreadActions();
|
||||
const { isMobile, setOpenMobile } = useSidebar();
|
||||
const routeThreadRef = useParams({
|
||||
strict: false,
|
||||
select: (params) => resolveThreadRouteRef(params),
|
||||
@@ -2855,12 +2875,15 @@ export default function Sidebar() {
|
||||
clearSelection();
|
||||
}
|
||||
setSelectionAnchor(scopedThreadKey(threadRef));
|
||||
if (isMobile) {
|
||||
setOpenMobile(false);
|
||||
}
|
||||
void navigate({
|
||||
to: "/$environmentId/$threadId",
|
||||
params: buildThreadRouteParams(threadRef),
|
||||
});
|
||||
},
|
||||
[clearSelection, navigate, setSelectionAnchor],
|
||||
[clearSelection, isMobile, navigate, setOpenMobile, setSelectionAnchor],
|
||||
);
|
||||
|
||||
const projectDnDSensors = useSensors(
|
||||
|
||||
Reference in new issue
Block a user