Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(sidebar): let the collapsed icon rail reorder bots

PepeNeifad79feb1b908
diff --git a/src/components/Sidebar.departments.test.ts b/src/components/Sidebar.departments.test.ts
index 4e7c06ab18..46080596dc 100644
--- a/src/components/Sidebar.departments.test.ts
+++ b/src/components/Sidebar.departments.test.ts
@@ -45,6 +45,7 @@ vi.mock("@/state/store", async (importOriginal) => {
import { initialState } from "@/state/store";
import { BOTS_SECTION_ID, CHANNELS_SECTION_ID, userSectionId } from "@/lib/sidebar-layout";
+import { SIDEBAR_DENSITY_KEY } from "@/lib/sidebar-preferences";
import { PHONE_LAYOUT } from "@/lib/use-media-query";
import { BotContextMenu, BotListItem, Sidebar, TeamMenuItems } from "./Sidebar";
import { NEW_DEPARTMENT } from "./SidebarBotDrag";
@@ -155,6 +156,18 @@ describe("Simple's sidebar before anyone drags", () => {
fixture.phone = true;
expect(rows().every((props) => props.botDrag === undefined)).toBe(true);
});
+
+ it("keeps every row draggable in the icons-only rail, where the whole tile is the drag source", () => {
+ // The rail (density "icons") collapses the sidebar to bot tiles. sections.interactive is false there, so the
+ // arrange used to answer with no drag handles at all and the rail could not be reordered.
+ fixture.storage.set(SIDEBAR_DENSITY_KEY, "avatars");
+ const icons = rows();
+ expect(icons.length).toBeGreaterThan(0);
+ for (const props of icons) {
+ expect(props.botDragging).toBe(false);
+ expect(props.botDrag!.row(props.bot.id).draggable).toBe(true);
+ }
+ });
});
describe("dragging a bot", () => {
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 0676953487..a85dd2a535 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1120,7 +1120,7 @@ export function Sidebar({ open, onClose, collapseToIcons = false }: {
for (const group of sectionedRooms) {
if (!sectionNames.includes(group.section!)) sectionNames.push(group.section!);
}
- const drops = botDrag.arrange({ enabled: sections.interactive && !phone, main: saved.unsectionedBots, sectioned: saved.sectionedBots, departments: sectionNames, bots: state.bots, taken: departmentNames(state) });
+ const drops = botDrag.arrange({ enabled: (sections.interactive || density === "icons") && !phone, main: saved.unsectionedBots, sectioned: saved.sectionedBots, departments: sectionNames, bots: state.bots, taken: departmentNames(state) });
const naturalSectionIds = [
...(pinnedBots.length > 0 && !universalPins && !simpleDesk ? [PINNED_SECTION_ID] : []),
...(unsectionedRooms.length > 0 ? [CHANNELS_SECTION_ID] : []),