Skip to content

Commit 23a18fd

Browse files
fix(plugin-report): a matrix lays out each header dimension on its own — a date axis by bucket key, a select axis in option order (#34380)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9C4PyYnJ5aNqKb43dZ6nK1k)_ Fixes #34364 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:数据集矩阵报表的行、列表头改为逐个维度决定顺序:报表 `order` 点名的维度保持服务端顺序;没点名的选项字段按声明的选项顺序;没点名的日期维度按桶键(原始值)升序,空桶排最后;其余维度保持到达顺序。 - **为什么改**:服务端空桶填充不运行时(分页、按度量排序、`compareTo`、超 2000 格),日期列按首次出现顺序排成一段段;而只要报表带任何 `order`,两条轴的选项顺序就都失效,按日期排序会把优先级行打乱成 Critical / High / Low / Medium。应用侧无法自救。 - **风险与回滚**:只动 `@object-ui/plugin-report` 的矩阵表头排列,单元格仍按桶 id 定位、下钻负载不变;平铺表和内嵌图表不变;无服务端或契约改动。回滚即 revert 本 PR。 - **先看**:`ui/packages/plugin-report/src/DatasetReportRenderer.tsx` 的 `matrixAxisComparators` 与 `compareDateBucketKeys`,以及矩阵 `pivot` 里调用 `arrangeGroups` 的两行;其次 `DatasetReportRenderer.selectOptionOrder-12243.test.tsx` 末尾 objectstack#34364 一组。 - **两分钟验证**:`pnpm --dir ui exec vitest run packages/plugin-report/src/__tests__/DatasetReportRenderer.selectOptionOrder-12243.test.tsx`,预期 15 个测试全过。 - **需要你做的**:无,席位落地。 ## What changes - **Per-dimension matrix layout.** The matrix no longer switches the layout off for the whole grid when the report carries an `order`. `matrixAxisComparators` decides each header dimension on its own: - named by the report's scoped `order` → kept in the server's order; - an unnamed select (declared-option ranks) → declared option order, read off the display value (unchanged objectui#12243 rule); - an unnamed date → bucket keys ascending (`compareDateBucketKeys`): the raw key in `h.key`, compared by code unit, never the localized label; two numbers compare numerically; the empty bucket last, as `declaredOptionPosition` does; - anything else → arrival order. - **Date-ness is read from the answer, not sniffed.** A dimension is a date when its `AnalyticsResult.fields[]` descriptor says `type: 'time'`, which the analytics compiler sets for every dataset `date` dimension at any `dateGranularity`. Bucket keys are minted sort-stable by the server (`2026-03`, `2026-Q1`, `2026-W03`, `2026-03-07`). - **Reading of card ask 1 (the seat's):** "whatever the query order" is read as "whatever order the server returned the rows in". An author's explicit order on the SAME date dimension (for example `desc`) is the author's and is kept; only an axis the order does not name is re-laid. Pinned by case (d). - **Only headers move.** `arrangeByDeclaredOptions` is now a thin wrapper over a generic `arrangeGroups` (same level-by-level, stable bucket sort, comparator supplied per dimension). The matrix permutes only `rowHeaders` / `colHeaders`; every cell is still looked up by bucket id and each header carries its own drill `key`, so drill payloads stay index-aligned. The flat table and the embedded chart keep their existing rule. - **Docs.** The file header ("Ordering") and the comments at the matrix query and at the layout call now say exactly this: sorting the axis HEADERS is not the forbidden client-side re-sort of rows. - **Memo key.** The pivot memo keys on a serialized list of the named dimensions, not on a per-render object (ui `AGENTS.md` #10). - Changeset: `.changeset/34364-matrix-date-axis-order.md` (`@object-ui/plugin-report`: patch). ## Tests New top-level `describe` in the existing ordering harness `DatasetReportRenderer.selectOptionOrder-12243.test.tsx` (reuses its `crm_case` priority options, metadata stub and dataset source). Matrix: rows `priority` (Low / Medium / High / Critical), columns `created_at` typed `time`, values `case_count`, rows arriving grouped by stored priority with days out of order and a null day (declared `nullLabel` "No date"): - (a) no order → columns `2026-11-03, 2026-11-12, 2026-11-14, 2026-11-16, No date`; rows Low, Medium, High, Critical with every cell under its own headers; a click on the first cell drills `{ priority: 'Low', created_at: '2026-11-03' }`. - (b) `order [{ by: case_count, desc }]` → the same layout. - (c) `order [{ by: created_at, asc }]` → columns ascend, rows STILL in option order. - (d) `order [{ by: created_at, desc }]` → columns descend (`No date` first, as the server sent), rows in option order. - CONTROL: `order [{ by: priority }]` → rows keep the server's order, day columns still ascend. The existing objectui#12243 cases and the framework#3916 matrix-order cases in `DatasetReportRenderer.test.tsx` pass unchanged. No forced edits to existing tests. ## Acceptance notes - None filed. Out of scope as the card says: which analytics version hosted runs (cloud seat), and the server-side fill. - The flat summary table and the embedded chart still switch their option layout off under any authored `order`; the card asks only about the matrix, and a flat table's row order under a measure order is the author's. ## Verification <details><summary>Tests (head 4c7d73b)</summary> - `pnpm --dir ui exec vitest run packages/plugin-report/src/__tests__/DatasetReportRenderer.selectOptionOrder-12243.test.tsx` → Test Files 1 passed, Tests 15 passed (on 2fc9d9d and again on 4c7d73b). - `4c7d73b7` changes only the test fixture: the `created_at` sort helper ordered the empty day with a raw U+FFFF sentinel character, now replaced by an explicit null branch (same order). - On 2fc9d9d (code unchanged since): `pnpm --dir ui exec vitest run packages/plugin-report/ --maxWorkers=2 && pnpm --filter @object-ui/plugin-report run type-check` → Test Files 33 passed (33), Tests 329 passed / 7 skipped; type-check done; lock VERDICT command-exit 0. - `pnpm --dir ui exec eslint` on the two changed files → exit 0 (0 errors; 5 pre-existing `react-refresh/only-export-components` warnings on existing exports). `pnpm --dir ui run check:new-line-citations` → 0 new citations. </details> <details><summary>Ablations (scripts/ablation-replace.mjs, mutation proven on disk, each restored to HEAD blob add203e)</summary> Directions were written into the test file before the runs. - A: the date comparator returns `null` → (a), (b) and CONTROL red (3 failed / 12 passed); (c), (d) green as predicted. Re-run on 4c7d73b with the same result. - B: `if (ordered.has(dim)) return null;` → `if (ordered.size > 0) return null;` (the old all-or-nothing rule) → (b), (c), (d) and CONTROL red (4 failed / 11 passed); (a) green. - C: the named-dimension check deleted → (d) and CONTROL red (2 failed / 13 passed). </details> <details><summary>Derived gate families</summary> Head `4c7d73b7` (re-run after the fixture commit; the list and every exit code match the run on 2fc9d9d), `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: 38 commands, all exit 0. `--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN. ```text node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-sdui-manifest.mjs :: exit 0 node scripts/check-sdui-manifest.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --dir ui exec vitest run scripts/ :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm check:adr-anchors :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:skill-identifier-liveness :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 ``` Every family CI runs is read from this PR's check-runs, not re-run here. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmSDShXaoKYWNqiKtAC)_ <!-- signed: domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2c296cf commit 23a18fd

3 files changed

Lines changed: 286 additions & 40 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/plugin-report': patch
3+
---
4+
5+
fix(plugin-report): a matrix report lays out each header dimension on its own, so a date axis reads by bucket key and a select axis keeps its option order whatever the report's `order`
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A dataset matrix collected its row and column headers in row-arrival order. When the server's empty-bucket fill and its default ascending time order did not run (a selection with limit/offset, an order on a measure, `compareTo`, or a grid over 2,000 cells), a date column axis came out in first-seen order: one ascending run per row bucket, end to end. And any report `order` switched off the select option layout on both axes, so ordering by the date dimension turned a `priority` row axis from Low / Medium / High / Critical into the stored-value order Critical / High / Low / Medium.
11+
12+
The matrix now decides per header dimension. A dimension the report's `order` names keeps the order the server applied, so an explicit `desc` on a date axis stays descending. A select dimension it does not name takes its declared option order, as before with no `order`. A date dimension it does not name (its answer column is typed `time`, at any `dateGranularity`) takes its bucket keys ascending, compared by the raw key and not the localized label, with the empty bucket last. Any other dimension keeps its arrival order.
13+
14+
Only the two header lists are permuted. Every cell is still placed by its bucket ids and every drill click still carries its own bucket, so no row is re-sorted and nothing a truncated page holds is reordered. Flat tables and embedded charts are unchanged.

‎ui/packages/plugin-report/src/DatasetReportRenderer.tsx‎

Lines changed: 135 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
* keys, most significant first — is lowered onto the dataset selection, so the
4848
* SERVER orders the whole grid (after measure-scoped filters merge and derived
4949
* measures evaluate) and this renderer only places the rows it is handed. It is
50-
* never a client-side re-sort: sorting here would order the truncated page
51-
* rather than the query, and could not sort by a derived measure at all.
50+
* never a client-side re-sort of the ROWS: sorting them here would order the
51+
* truncated page rather than the query, and could not sort by a derived measure
52+
* at all.
5253
*
5354
* Declaring NO `order` leaves the grid in the dataset's `GROUP BY` order — the
5455
* stored values' alphabetical order — which for a select dimension is not the
@@ -61,11 +62,27 @@
6162
* nothing the server ordered on the author's behalf (see
6263
* `arrangeByDeclaredOptions`).
6364
*
64-
* For a matrix that also decides the ACROSS axis: `colHeaders` are collected in
65-
* row-arrival order, so ordering the rows by the across dimension is what makes
66-
* the columns read left-to-right in that order. Declaring nothing still reads
67-
* correctly — the server defaults a selected time dimension to ascending, which
68-
* is what makes month/quarter columns chronological out of the box.
65+
* A matrix decides its two axes PER DIMENSION, not per report (objectstack#34364).
66+
* Its headers are collected in row-arrival order, and the arrival order of one
67+
* axis's buckets says nothing reliable once the rows are ordered by anything
68+
* else: the server's empty-bucket fill and its default ascending time order do
69+
* not run under limit/offset, a measure order, `compareTo` or a large grid, and
70+
* then a date axis arrives in first-seen order (one ascending run per row
71+
* bucket, end to end). So each header dimension is laid out on its own:
72+
*
73+
* - a dimension the report's scoped `order` NAMES keeps the server's order — an
74+
* author's explicit order on it (`desc` included) is the author's;
75+
* - a select dimension it does not name takes its declared option order (the
76+
* rule above);
77+
* - a date dimension it does not name (its answer column types `time`, at any
78+
* `dateGranularity`) takes its bucket KEYS ascending — the raw values, minted
79+
* sort-stable by the server, never the localized label — the empty bucket
80+
* last;
81+
* - any other dimension keeps its arrival order.
82+
*
83+
* Sorting the HEADERS is not the client-side re-sort ruled out above: the pivot
84+
* places every cell by its bucket ids, so no row moves, no page is re-sorted and
85+
* no measure is re-ordered — only the two header lists are permuted.
6986
*
7087
* Drill-down (ADR-0021 D2): when the report's `drilldown` flag is not `false`
7188
* and the host supplies `onDrill`, every aggregated row / matrix cell is
@@ -483,9 +500,11 @@ function declaredOptionPosition(value: unknown, rank: ReadonlyMap<string, number
483500
* dataset's order among themselves); a dimension without keeps arrival order;
484501
* - each bucket is then laid out by the next level.
485502
*
486-
* `null` — nothing moves — when no dimension declares options, and the caller
487-
* passes `null` ranks when the report declares its own `order`: an author's
488-
* explicit order is the author's, and the server already applied it.
503+
* `null` — nothing moves — when no dimension declares options. The table and
504+
* the chart pass `null` ranks when the report declares its own `order`: an
505+
* author's explicit order is the author's, and the server already applied it.
506+
* The matrix passes, per dimension, no rank for a dimension that order names
507+
* (see `matrixAxisComparators`).
489508
*
490509
* Indices, never a reordered copy of the rows: the drill payload is read off
491510
* `state.rows[i]` / `drillRawRows[i]` / `drillRanges[i]`, which stay aligned
@@ -497,7 +516,47 @@ function arrangeByDeclaredOptions<T>(
497516
valueOf: (item: T, dim: string) => unknown,
498517
ranks: DimensionRanks | null,
499518
): number[] | null {
500-
if (!ranks || !dims.some((d) => ranks[d])) return null;
519+
if (!ranks) return null;
520+
return arrangeGroups(items, dims, valueOf, (dim) => {
521+
const rank = ranks[dim];
522+
return rank
523+
? (a, b) => declaredOptionPosition(valueOf(a, dim), rank) - declaredOptionPosition(valueOf(b, dim), rank)
524+
: null;
525+
});
526+
}
527+
528+
/**
529+
* Where one date bucket sits on its axis (objectstack#34364): by its KEY — the
530+
* raw value the server minted sort-stable (`2026-03`, `2026-Q1`, `2026-W03`,
531+
* `2026-03-07`, or an ISO instant), compared as a string by code unit, never the
532+
* localized label — ascending, the empty bucket last as in
533+
* {@link declaredOptionPosition}. Two numbers compare as numbers.
534+
*/
535+
function compareDateBucketKeys(a: unknown, b: unknown): number {
536+
const aEmpty = a == null || a === '';
537+
const bEmpty = b == null || b === '';
538+
if (aEmpty || bEmpty) return aEmpty === bEmpty ? 0 : aEmpty ? 1 : -1;
539+
if (typeof a === 'number' && typeof b === 'number') return a - b;
540+
const sa = String(a);
541+
const sb = String(b);
542+
return sa < sb ? -1 : sa > sb ? 1 : 0;
543+
}
544+
545+
/**
546+
* The level-by-level layout {@link arrangeByDeclaredOptions} describes, with
547+
* the ORDER of each level's buckets supplied per dimension: `compareFor(dim)`
548+
* compares two items' buckets at that level, or is `null` to keep the buckets in
549+
* arrival order. Items are bucketed by `valueOf`, the sort is STABLE, and the
550+
* answer is `null` — nothing moves — when no level has a comparator.
551+
*/
552+
function arrangeGroups<T>(
553+
items: readonly T[],
554+
dims: readonly string[],
555+
valueOf: (item: T, dim: string) => unknown,
556+
compareFor: (dim: string) => ((a: T, b: T) => number) | null,
557+
): number[] | null {
558+
const comparators = dims.map((d) => compareFor(d));
559+
if (!comparators.some(Boolean)) return null;
501560
const arrange = (indices: number[], level: number): number[] => {
502561
if (level >= dims.length || indices.length < 2) return indices;
503562
const dim = dims[level];
@@ -509,14 +568,8 @@ function arrangeByDeclaredOptions<T>(
509568
else buckets.set(id, [i]);
510569
}
511570
const groups = [...buckets.values()];
512-
const rank = ranks[dim];
513-
if (rank) {
514-
groups.sort(
515-
(a, b) =>
516-
declaredOptionPosition(valueOf(items[a[0]], dim), rank) -
517-
declaredOptionPosition(valueOf(items[b[0]], dim), rank),
518-
);
519-
}
571+
const compare = comparators[level];
572+
if (compare) groups.sort((a, b) => compare(items[a[0]], items[b[0]]));
520573
return groups.flatMap((group) => arrange(group, level + 1));
521574
};
522575
return arrange(items.map((_, i) => i), 0);
@@ -1907,6 +1960,42 @@ function bucketLabel(
19071960
return dims.map((d) => dimensionText(fields, d, row[d], locale)).join(' / ');
19081961
}
19091962

1963+
/** One matrix axis header: the RAW bucket (`key`) and how it reads (`display`). */
1964+
type MatrixHeader = { id: string; label: string; key: Row; display: Row };
1965+
1966+
/**
1967+
* How a matrix lays out each header dimension (objectstack#34364), decided per
1968+
* DIMENSION rather than per report — the comparator `arrangeGroups` sorts that
1969+
* level's buckets by, or `null` to keep the server's arrival order:
1970+
*
1971+
* - named by the report's scoped `order` → `null`: the author's order, which
1972+
* the server applied (an explicit `desc` on a date axis stays descending);
1973+
* - a select (it has declared-option `ranks`) → its declared option order,
1974+
* read off the DISPLAY value (objectui#12243);
1975+
* - a date → its bucket KEY ascending ({@link compareDateBucketKeys}). Date-ness
1976+
* is read off the answer's own column descriptor — a date dimension's column
1977+
* is typed `time` (`AnalyticsResult.fields[].type`) at every
1978+
* `dateGranularity` — never sniffed from the values;
1979+
* - anything else → `null`.
1980+
*/
1981+
function matrixAxisComparators(
1982+
fields: readonly DatasetResultField[] | undefined,
1983+
ranks: DimensionRanks | null,
1984+
ordered: ReadonlySet<string>,
1985+
): (dim: string) => ((a: MatrixHeader, b: MatrixHeader) => number) | null {
1986+
return (dim) => {
1987+
if (ordered.has(dim)) return null;
1988+
const rank = ranks?.[dim];
1989+
if (rank) {
1990+
return (a, b) => declaredOptionPosition(a.display[dim], rank) - declaredOptionPosition(b.display[dim], rank);
1991+
}
1992+
if (fields?.find((f) => f.name === dim)?.type === 'time') {
1993+
return (a, b) => compareDateBucketKeys(a.key[dim], b.key[dim]);
1994+
}
1995+
return null;
1996+
};
1997+
}
1998+
19101999
/**
19112000
* True cross-tab for `type: 'matrix'` — one dataset query over
19122001
* `[...rows, ...columns]`, pivoted client-side. Cells show every measure
@@ -1941,9 +2030,9 @@ function DatasetMatrixTable({
19412030
// objectstack-ai/objectstack#3916: the ordering rides on the PRIMARY query only — the server drops it
19422031
// for the totals sub-queries by design (a total covers the whole selection,
19432032
// and an order key may name a dimension the totals grouping doesn't have).
1944-
// The across-axis header sequence follows from it: `pivot` below collects
1945-
// `colHeaders` in row-ARRIVAL order, so ordering the rows by the across
1946-
// dimension is what makes the columns read left-to-right in that order.
2033+
// `pivot` below collects both header lists in row-ARRIVAL order, so a header
2034+
// dimension the order NAMES reads in the order the server applied; every
2035+
// other header dimension is laid out per `matrixAxisComparators`.
19472036
const state = useDatasetRows(
19482037
dataset,
19492038
[...rows, ...columnsAcross],
@@ -1972,18 +2061,20 @@ function DatasetMatrixTable({
19722061
() => deriveDimensionDisplay(dimensionMeta, fieldOptionLabel),
19732062
[dimensionMeta, fieldOptionLabel],
19742063
);
1975-
// objectui#12243 — a report that declares its own `order` for this selection
1976-
// keeps the server's arrival order on both axes; otherwise each axis is laid
1977-
// out in its select dimensions' declared option order.
1978-
const hasAuthoredOrder = scopeOrder(order, [...rows, ...columnsAcross], values) !== undefined;
2064+
// objectstack#34364 — the keys of the report's `order` this selection
2065+
// carries, read PER DIMENSION: a header dimension it names keeps the server's
2066+
// order; every other one is laid out by the renderer (see
2067+
// `matrixAxisComparators`). Serialized so the pivot memo keys on the names,
2068+
// not on an object rebuilt every render.
2069+
const orderedDimensionsKey = JSON.stringify(Object.keys(scopeOrder(order, [...rows, ...columnsAcross], values) ?? {}));
19792070

19802071
const pivot = React.useMemo(() => {
19812072
if (state.status !== 'ok') return null;
19822073
// `key` is the RAW bucket (drill identity); `display` is the same bucket as
19832074
// it reads on screen, per dimension — the two are deliberately separate
19842075
// (objectui#4330).
1985-
const rowHeaders: Array<{ id: string; label: string; key: Row; display: Row }> = [];
1986-
const colHeaders: Array<{ id: string; label: string; key: Row; display: Row }> = [];
2076+
const rowHeaders: MatrixHeader[] = [];
2077+
const colHeaders: MatrixHeader[] = [];
19872078
const seenRow = new Set<string>();
19882079
const seenCol = new Set<string>();
19892080
const cells = new Map<string, { row: Row; index: number }>();
@@ -2019,17 +2110,21 @@ function DatasetMatrixTable({
20192110
// server's own row.
20202111
cells.set(pivotCellKey(rid, cid), { row: raw, index });
20212112
});
2022-
// objectui#12243 — the headers were collected in row-ARRIVAL order, which
2023-
// with no authored `order` is the dataset's `GROUP BY` order (alphabetical
2024-
// by stored value). Each axis is laid out by its own dimensions' declared
2025-
// option order, read off the DISPLAY values the headers carry, so a
2026-
// `priority` column axis reads Low, Medium, High as a `status` row axis
2027-
// reads New, In Progress, Closed. A time or text dimension keeps its
2028-
// arrival order (the server's chronological default for a time axis).
2029-
// Only the header lists move: every cell is still looked up by bucket id.
2030-
const ranks = hasAuthoredOrder ? null : dimensionRanks;
2031-
const rowLayout = arrangeByDeclaredOptions(rowHeaders, rows, (h, d) => h.display[d], ranks);
2032-
const colLayout = arrangeByDeclaredOptions(colHeaders, columnsAcross, (h, d) => h.display[d], ranks);
2113+
// The headers were collected in row-ARRIVAL order, which says nothing
2114+
// reliable about either axis once the rows are ordered by anything else.
2115+
// Each header dimension is laid out on its own (objectstack#34364): one the
2116+
// report's `order` names keeps that arrival order, an unnamed select takes
2117+
// its declared option order read off the DISPLAY values (objectui#12243),
2118+
// an unnamed date takes its bucket KEYS ascending, anything else stays put.
2119+
// This permutes only the two header lists, never a row: every cell is still
2120+
// looked up by bucket id, and each header carries its own drill `key`.
2121+
const comparatorsFor = matrixAxisComparators(
2122+
state.fields,
2123+
dimensionRanks,
2124+
new Set<string>(JSON.parse(orderedDimensionsKey) as string[]),
2125+
);
2126+
const rowLayout = arrangeGroups(rowHeaders, rows, (h, d) => h.display[d], comparatorsFor);
2127+
const colLayout = arrangeGroups(colHeaders, columnsAcross, (h, d) => h.display[d], comparatorsFor);
20332128
return {
20342129
rowHeaders: rowLayout ? rowLayout.map((i) => rowHeaders[i]) : rowHeaders,
20352130
colHeaders: colLayout ? colLayout.map((i) => colHeaders[i]) : colHeaders,
@@ -2041,7 +2136,7 @@ function DatasetMatrixTable({
20412136
// that switches locale without refetching keeps the previous locale's
20422137
// headers, and the pin for that is the "re-labels the across header when
20432138
// only the locale changes" case in DatasetReportRenderer.measureLocale.test.tsx.
2044-
}, [state, rows, columnsAcross, dimensionLabels, dimensionRanks, hasAuthoredOrder, displayLocale]);
2139+
}, [state, rows, columnsAcross, dimensionLabels, dimensionRanks, orderedDimensionsKey, displayLocale]);
20452140

20462141
if (values.length === 0) return <EmptyMeasures dataset={dataset} />;
20472142
if (state.status === 'loading' || state.status === 'idle') return <FetchStates status={state.status} />;

0 commit comments

Comments
 (0)