Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(issues): name the sort in the board's drag hint (#11460)

pseudoyud1f9ac12b79e
diff --git a/packages/views/issues/components/board-view-project-grouping.test.tsx b/packages/views/issues/components/board-view-project-grouping.test.tsx
index 2d73361834..fb53b3c5aa 100644
--- a/packages/views/issues/components/board-view-project-grouping.test.tsx
+++ b/packages/views/issues/components/board-view-project-grouping.test.tsx
@@ -12,6 +12,7 @@ import { cleanup, screen } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ViewStoreProvider } from "@multica/core/issues/stores/view-store-context";
import { getIssueSurfaceViewStore } from "@multica/core/issues/stores/surface-view-store";
+import type { SortField } from "@multica/core/issues/stores/view-store";
import type { Issue, Project } from "@multica/core/types";
import { renderWithI18n } from "../../test/i18n";
import { IssueContextMenuProvider } from "../actions/issue-actions-context-menu";
@@ -22,6 +23,19 @@ import {
type ScrollRestorationAdapter,
} from "../../platform";
+// jsdom has no layout, so dnd-kit never reports a hovered column by itself.
+const drag = vi.hoisted(() => ({ isOver: false }));
+vi.mock("@dnd-kit/core", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@dnd-kit/core")>();
+ return {
+ ...actual,
+ useDroppable: (args: Parameters<typeof actual.useDroppable>[0]) => ({
+ ...actual.useDroppable(args),
+ isOver: drag.isOver,
+ }),
+ };
+});
+
vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));
vi.mock("@multica/core/properties", async (importOriginal) => ({
@@ -195,21 +209,25 @@ describe("Board grouped by project", () => {
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
+ drag.isOver = false;
});
function render({
descriptors = [NO_PROJECT_DESCRIPTOR, ...PROJECT_DESCRIPTORS],
issues = ISSUES,
scrollAdapter = { get: () => undefined },
+ sortBy,
}: {
descriptors?: IssueGroupBranches["descriptors"];
issues?: Issue[];
scrollAdapter?: ScrollRestorationAdapter;
+ sortBy?: SortField;
} = {}) {
const store = getIssueSurfaceViewStore(
`board-project-${Math.floor(Math.random() * 1e9)}`,
);
store.getState().setGrouping("project");
+ if (sortBy) store.getState().setSortBy(sortBy);
// Cards carry their own project chip by default, which would put the same
// title in two places and make "the column header says X" unprovable.
if (store.getState().cardProperties.project) {
@@ -298,6 +316,17 @@ describe("Board grouped by project", () => {
expect(acmeColumn.textContent).not.toContain("MUL-loose");
});
+ it.each([
+ ["the default sort", undefined, "Updated date"],
+ ["created date", "created_at", "Created date"],
+ ["priority", "priority", "Priority"],
+ ] as const)("names %s in the hint a hovered column shows", (_, sortBy, field) => {
+ drag.isOver = true;
+ render({ sortBy });
+
+ expect(screen.getAllByText(`Board ordered by ${field}`).length).toBeGreaterThan(0);
+ });
+
it("brings the column strip back to where it was scrolled sideways", () => {
render({
scrollAdapter: {
diff --git a/packages/views/issues/components/board-view.tsx b/packages/views/issues/components/board-view.tsx
index 059116ac3b..17083e9bb8 100644
--- a/packages/views/issues/components/board-view.tsx
+++ b/packages/views/issues/components/board-view.tsx
@@ -27,7 +27,7 @@ import { useViewStore } from "@multica/core/issues/stores/view-store-context";
import { propertyIdFromViewKey } from "@multica/core/issues/stores/view-store";
import { propertyListOptions, useSetIssueProperty, useUnsetIssueProperty } from "@multica/core/properties";
import { useWorkspaceId } from "@multica/core/hooks";
-import type { IssueGrouping } from "@multica/core/issues/stores/view-store";
+import type { IssueGrouping, StaticSortField } from "@multica/core/issues/stores/view-store";
import { useActorName } from "@multica/core/workspace/hooks";
import { BoardColumn, BOARD_CARD_WIDTH, type BoardColumnGroup } from "./board-column";
import { BoardWorkflowContext, type BoardWorkflowContextValue } from "./board-workflow-context";
@@ -55,6 +55,7 @@ import type {
IssueGroupBranches,
IssueGroupPageState,
} from "../surface/use-issue-group-branches";
+import { SORT_LABEL_KEY } from "../utils/sort-label";
import { useDragSettle } from "./use-drag-settle";
import { createIssueDropAnimation, ISSUE_DRAG_OVERLAY_CLASS } from "./drag-drop-animation";
import { useIssuePeekActions } from "../surface/peek-context";
@@ -337,13 +338,12 @@ function BoardViewImpl({
},
[setIssuePropertyMutation, t, unsetIssuePropertyMutation],
);
- const sortFieldKey = sortBy === "created_at" ? "created" : sortBy;
const sortPropertyId = propertyIdFromViewKey(sortBy);
const sortLabel = sortBy !== "position"
? t(($) => $.board.ordered_by, {
field: sortPropertyId
? workspaceProperties.find((p) => p.id === sortPropertyId)?.name ?? ""
- : t(($) => $.display[`sort_${sortFieldKey}` as keyof typeof $.display]),
+ : t(($) => $.display[SORT_LABEL_KEY[sortBy as StaticSortField]]),
})
: null;
const { getActorName } = useActorName();
diff --git a/packages/views/issues/components/issues-header.tsx b/packages/views/issues/components/issues-header.tsx
index 5978a60c45..40dd3e305c 100644
--- a/packages/views/issues/components/issues-header.tsx
+++ b/packages/views/issues/components/issues-header.tsx
@@ -98,9 +98,9 @@ import { useProjectStatusLabels } from "../../projects/components/labels";
import { ActorAvatar } from "../../common/actor-avatar";
import { PropertyIcon } from "../../common/property-icon";
import { sortDirectionLabelKey } from "../utils/sort-direction";
+import { SORT_LABEL_KEY } from "../utils/sort-label";
import { LabelChip } from "../../labels/label-chip";
import {
- SORT_OPTIONS,
GROUPING_OPTIONS,
SWIMLANE_GROUPINGS,
CARD_PROPERTY_OPTIONS,
@@ -1992,16 +1992,6 @@ export function IssueDisplayControls({
);
const hasActiveFilters = activeFilterCount > 0;
- const SORT_LABEL_KEY: Record<typeof SORT_OPTIONS[number]["value"], "sort_manual" | "sort_status" | "sort_priority" | "sort_start_date" | "sort_due_date" | "sort_created" | "sort_updated" | "sort_title"> = {
- position: "sort_manual",
- status: "sort_status",
- priority: "sort_priority",
- start_date: "sort_start_date",
- due_date: "sort_due_date",
- created_at: "sort_created",
- updated_at: "sort_updated",
- title: "sort_title",
- };
const GROUPING_LABEL_KEY: Record<typeof GROUPING_OPTIONS[number]["value"], "group_status" | "group_assignee" | "group_project"> = {
status: "group_status",
assignee: "group_assignee",
diff --git a/packages/views/issues/components/list-view.tsx b/packages/views/issues/components/list-view.tsx
index 87cf5103dd..31798c9d01 100644
--- a/packages/views/issues/components/list-view.tsx
+++ b/packages/views/issues/components/list-view.tsx
@@ -103,10 +103,7 @@ function ListViewImpl({
const wsId = useWorkspaceId();
const catalog = useIssueStatuses(wsId);
- const sortFieldKey = sortBy === "created_at" ? "created" : sortBy;
- const sortLabel = sortBy !== "position"
- ? t(($) => $.board.ordered_by, { field: t(($) => $.display[`sort_${sortFieldKey}` as keyof typeof $.display]) })
- : null;
+ const disableSorting = sortBy !== "position";
const expandedStatuses = useMemo(
() =>
@@ -421,7 +418,7 @@ function ListViewImpl({
onCreateIssue={onCreateIssue}
dragEnabled={dragEnabled}
isExpanded={isExpanded}
- sortLabel={sortLabel}
+ disableSorting={disableSorting}
scrollParent={scrollEl}
rowHeight={rowHeight}
/>
@@ -475,7 +472,7 @@ function StatusAccordionItem({
onCreateIssue,
dragEnabled,
isExpanded,
- sortLabel,
+ disableSorting,
scrollParent,
rowHeight,
}: {
@@ -489,7 +486,7 @@ function StatusAccordionItem({
onCreateIssue?: (defaults: IssueCreateDefaults) => void;
dragEnabled: boolean;
isExpanded: boolean;
- sortLabel: string | null;
+ disableSorting: boolean;
scrollParent: HTMLElement | null;
rowHeight: number | undefined;
}) {
@@ -519,7 +516,6 @@ function StatusAccordionItem({
});
const isOver = droppableIsOver && !statusCatalog.entryOf(status)?.archived_at;
- const disableSorting = !!sortLabel;
const addIssueLabel = t(($) => $.list.add_issue_tooltip);
// The infinite-scroll sentinel rides Virtuoso's Footer so it sits at the true
diff --git a/packages/views/issues/utils/sort-label.ts b/packages/views/issues/utils/sort-label.ts
new file mode 100644
index 0000000000..149375a053
--- /dev/null
+++ b/packages/views/issues/utils/sort-label.ts
@@ -0,0 +1,13 @@
+import type { StaticSortField } from "@multica/core/issues/stores/view-store";
+
+/** The `display.*` string that names each sort field. */
+export const SORT_LABEL_KEY = {
+ position: "sort_manual",
+ status: "sort_status",
+ priority: "sort_priority",
+ start_date: "sort_start_date",
+ due_date: "sort_due_date",
+ created_at: "sort_created",
+ updated_at: "sort_updated",
+ title: "sort_title",
+} as const satisfies Record<StaticSortField, string>;