Commit bac266c
* feat(components,grid,list): a column-header sort orders the whole list, not the page you can see (#3106)
Clicking a column header under server pagination sorted the CURRENT PAGE. The
user saw "sorted by this column" and got "these fifty rows are in order; page 2
starts over". The sort was real — its scope was not the one the screen implied
— and it had no way out of `data-table` at all: it lived in two `useState`s
with no callback, so the layer that issues the request could not see it even in
principle.
DataTable gains `manualSorting` + a controlled `sort` + `onSortChange`. In that
mode it sorts nothing, reports what a header click asks for, and renders `sort`
as the indicator — holding NO sort state of its own, because a private copy
beside a controlled prop is the shape the defect had. `manualSorting` is
independent of `manualPagination`: what matters is whether `data` is a window,
not who owns the pager.
ObjectGrid turns that into a `$orderby` in both of its server modes (its own
fetch and a parent-driven one) and returns to page 1, since a new ordering
makes the old page index a different set of rows. ListView lands it in
`currentSort` — the same state the toolbar's sort builder writes. One sort with
two controls onto it is what makes "does a header sort outrank the saved view's
sort?" a non-question rather than a precedence rule someone has to remember.
Three decisions worth naming:
- A header click REPLACES the order rather than appending, so the column under
the cursor is the one the list is sorted by. Multi-key orders still come from
the sort builder, and the headers render them numbered.
- It cannot ask for "no sort". The third click clears in client mode, which is
meaningful there (rows return to the order they arrived in); across a
server-paged collection there is no such order (objectstack#4363), so a header
offering it would hand the user a worse lie than the one being fixed.
- Relational columns render no sort affordance under server sorting: a `lookup`
column shows a related record's name while `$orderby` can only order by the
stored id (objectstack#4256) — the same reason #3096 removed them from the
toolbar's picker. Client-side sorting keys off the rendered label, so those
headers stay live there.
The header context menu's Sort Ascending/Descending items now route through the
same write path; they wrote internal state directly, which under `manualSorting`
would have been a menu item that highlights, closes, and changes nothing.
Client-side tables are untouched: same three-state cycle, same local sort.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(detail): a related list has one sorting semantics instead of two (#3106)
A related list carried two. Its own sort-button row (opt-in via `sortable`) went
out as a server `$orderby` over the whole child collection; the `data-table` it
embeds took `sortable`'s default of `true` and sorted the rows it was holding —
which, in windowed mode, is ONE PAGE.
Turning `sortable` on put both in the same card with nothing saying they meant
different things. Leaving it off — the default — was worse: the page-local sort
was then the only one the user could reach, and it looked exactly like the list
being sorted.
The embedded table's column headers now drive this list's sort in both modes:
- Windowed: the header sort becomes the server `$orderby` and resets to page
one, the same path the buttons took.
- Client mode: this list keeps sorting in memory, where the key is the label
resolved through its own id → name map (#3096) — a key the table cannot see,
so its sort was the worse of the two even where both were possible.
The button row survives only where there are no headers to click: a `list`
(`data-list`) related list, or a caller-supplied `schema` whose contents we
cannot assume. `sortable`'s doc comment now says that is what it controls.
Relational columns keep #3096's rule, moved to the header: withheld while the
sort is a server `$orderby` (the key would be the stored foreign-key id while
the cell shows a name), live in client mode where the key is the label.
Three existing suites asserted through the sort buttons — two on #3096's own
guarantee, one using them as a proxy for column order. They now read the
column's `sortable` flag and drive the table's `onSortChange`, so the
guarantees they encode survive the control that carried them.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 24e0e0a commit bac266c
6 files changed
Lines changed: 410 additions & 21 deletions
File tree
- .changeset
- packages/plugin-detail/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
115 | 125 | | |
116 | 126 | | |
117 | 127 | | |
| |||
591 | 601 | | |
592 | 602 | | |
593 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
594 | 636 | | |
595 | 637 | | |
596 | 638 | | |
| |||
836 | 878 | | |
837 | 879 | | |
838 | 880 | | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
839 | 911 | | |
840 | 912 | | |
841 | 913 | | |
| |||
883 | 955 | | |
884 | 956 | | |
885 | 957 | | |
886 | | - | |
| 958 | + | |
887 | 959 | | |
888 | 960 | | |
889 | 961 | | |
890 | 962 | | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
891 | 976 | | |
892 | 977 | | |
893 | 978 | | |
| |||
907 | 992 | | |
908 | 993 | | |
909 | 994 | | |
910 | | - | |
| 995 | + | |
911 | 996 | | |
912 | 997 | | |
913 | 998 | | |
| |||
1008 | 1093 | | |
1009 | 1094 | | |
1010 | 1095 | | |
1011 | | - | |
1012 | | - | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1013 | 1105 | | |
1014 | 1106 | | |
1015 | 1107 | | |
| |||
0 commit comments