Fix collapsed starred project indentation
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
555391fed7
commit
e57d14343d
|
|
@ -112,6 +112,10 @@ function projectLinkLabels(container: HTMLElement) {
|
|||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function projectLink(container: HTMLElement, projectRef: string) {
|
||||
return container.querySelector(`a[href="/projects/${projectRef}/issues"]`) as HTMLAnchorElement | null;
|
||||
}
|
||||
|
||||
describe("SidebarStarredProjects", () => {
|
||||
let container: HTMLDivElement;
|
||||
let root: ReturnType<typeof createRoot> | null;
|
||||
|
|
@ -176,6 +180,30 @@ describe("SidebarStarredProjects", () => {
|
|||
expect(document.body.querySelector('button[aria-label="Unstar Bravo"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it("keeps starred projects indented only outside the collapsed rail", async () => {
|
||||
mockProjectsApi.list.mockResolvedValue([
|
||||
makeProject({ id: "project-a", name: "Alpha", urlKey: "alpha" }),
|
||||
]);
|
||||
memberships = { ...memberships, starredProjectIds: ["project-a"] };
|
||||
|
||||
await render();
|
||||
|
||||
expect(projectLink(container, "alpha")?.className).toContain("pl-8");
|
||||
|
||||
await act(async () => root?.unmount());
|
||||
root = null;
|
||||
container.innerHTML = "";
|
||||
queryClient = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } });
|
||||
mockSidebarState.collapsed = true;
|
||||
|
||||
await render();
|
||||
|
||||
const railProjectLink = projectLink(container, "alpha");
|
||||
expect(railProjectLink?.className).not.toContain("pl-8");
|
||||
const nameSpan = Array.from(container.querySelectorAll("span")).find((el) => el.textContent === "Alpha");
|
||||
expect(nameSpan?.className).toContain("w-0");
|
||||
});
|
||||
|
||||
it("renders nothing when no projects are starred", async () => {
|
||||
mockProjectsApi.list.mockResolvedValue([makeProject({ id: "project-a", name: "Alpha" })]);
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,8 @@ export function SidebarStarredProjects() {
|
|||
if (isMobile) setSidebarOpen(false);
|
||||
}}
|
||||
className={cn(
|
||||
"flex min-w-0 flex-1 items-center gap-2.5 px-3 py-1.5 pl-8 pointer-coarse:py-1 pr-8 text-(length:--text-compact) font-medium transition-colors",
|
||||
"flex min-w-0 flex-1 items-center gap-2.5 px-3 py-1.5 pointer-coarse:py-1 pr-8 text-(length:--text-compact) font-medium transition-colors",
|
||||
!rail && "pl-8",
|
||||
isActive
|
||||
? "bg-accent text-foreground"
|
||||
: "text-foreground/80 hover:bg-accent/50 hover:text-foreground",
|
||||
|
|
|
|||
Loading…
Reference in New Issue