forge
Explore
Log in

Don't you dare go Hollow

📊 align table headers with cells, fix page-size + inline averages

Browse files at this commit

72a2390dc677cf4607d9b81a746cf7a8894e4965Burak BoduroğluParent: 23adf31
  • fix
    • 📊 align table headers with cells, fix page-size + inline averages
Show full message
fix: 📊 align table headers with cells, fix page-size + inline averages
- drop text-align from `.data-table th`: the `.data-table th` rule
  out-specified per-column text-right/center utilities and forced every
  header left while cells aligned fine (header/cell mismatch)
- add `meta.align` to DataTable as the single source of alignment for both
  head and cell; sort button offsets by align instead of a blanket -ml-3
- migrate numeric columns (marks/attendance/homework reports, my-students,
  student-marks) off ad-hoc header spans to meta.align
- add opt-in `meta.stickyLeft` frozen-left column + `meta.divider` and a
  directional border/shadow seam; rename sticky-right
  classes; clearer sort icons (ChevronsUpDown → ArrowUp/ArrowDown)
- TablePagination: always include the active page size in the options so
  the selector shows a value instead of blank on non-standard sizes
- standardize the generic 12-row list default to 10 across pages
- student-marks: re-materialize table data when the per-student marks
  resource resolves so the inline average fills in without needing a sort
src/components/attendance/attendance-report-view.tsxmodified+7 -6
@@ -33,16 +33,17 @@ export function AttendanceReportView(props: { report: AttendanceReport; compact?
3333 {
3434 id: "course",
3535 header: t("nav.courses"),
36+ meta: { stickyLeft: true },
3637 cell: (cell) => (
3738 <Link to="/courses/$id" params={{ id: cell.row.original.course.id }} class="block truncate font-medium hover:text-primary hover:underline">
3839 {cell.row.original.course.title}
3940 </Link>
4041 ),
4142 },
42- ...ATTENDANCE_STATUSES.map((status) => ({
43+ ...ATTENDANCE_STATUSES.map((status, index) => ({
4344 id: status.value,
4445 header: () => <span title={t(status.detailKey)}>{compact() ? t(status.key).slice(0, 1) : t(status.key)}</span>,
45- meta: { headerClass: "text-right", cellClass: "text-right" },
46+ meta: { align: "right" as const, divider: index === 0 ? ("left" as const) : undefined },
4647 cell: (cell) => (
4748 <span class={cn("mono inline-flex min-w-7 justify-center rounded-md border px-1.5 py-0.5 text-[11px] font-semibold tabular-nums", status.class)}>
4849 {cell.row.original.counts[status.value]}
@@ -51,14 +52,14 @@ export function AttendanceReportView(props: { report: AttendanceReport; compact?
5152 } satisfies ColumnDef<CourseAttendanceRow>)),
5253 {
5354 id: "total",
54- header: () => <span class="block text-right">{compact() ? "Σ" : t("common.all")}</span>,
55- meta: { cellClass: "mono text-right" },
55+ header: () => <span>{compact() ? "Σ" : t("common.all")}</span>,
56+ meta: { align: "right", cellClass: "mono" },
5657 cell: (cell) => cell.row.original.counts.total,
5758 },
5859 {
5960 id: "rate",
60- header: () => <span class="block text-right">%</span>,
61- meta: { cellClass: "mono text-right font-semibold" },
61+ header: () => <span>%</span>,
62+ meta: { align: "right", cellClass: "mono font-semibold" },
6263 cell: (cell) => percent(cell.row.original.counts.rate),
6364 },
6465 ]);
src/components/homework/homework-report-view.tsxmodified+1 -1
@@ -56,7 +56,7 @@ export function HomeworkReportView(props: { userId: string }) {
5656 {
5757 id: "mark",
5858 header: t("form.mark"),
59- meta: { cellClass: "text-right font-medium tabular-nums" },
59+ meta: { align: "right", cellClass: "font-medium tabular-nums" },
6060 cell: (cell) => cell.row.original.result?.mark ?? "—",
6161 },
6262 {
src/components/marks/marks-report-view.tsxmodified+5 -4
@@ -33,6 +33,7 @@ export function MarksReportView(props: { report: MarksReport; compact?: boolean
3333 {
3434 accessorKey: "title",
3535 header: t("marks.exam"),
36+ meta: { stickyLeft: true },
3637 cell: (cell) => (
3738 <span class="min-w-0">
3839 <ExamLink examId={cell.row.original.exam} class="block truncate font-medium hover:underline">
@@ -54,14 +55,14 @@ export function MarksReportView(props: { report: MarksReport; compact?: boolean
5455 },
5556 {
5657 id: "weight",
57- header: () => <span class="block text-right">{t("marks.weight")}</span>,
58- meta: { cellClass: "mono text-right" },
58+ header: t("marks.weight"),
59+ meta: { align: "right", divider: "left", cellClass: "mono" },
5960 cell: (cell) => examWeight(cell.row.original, settings()?.exam_kinds) ?? "—",
6061 },
6162 {
6263 accessorKey: "mark",
63- header: () => <span class="block text-right">{t("marks.mark")}</span>,
64- meta: { cellClass: "mono text-right font-semibold" },
64+ header: t("marks.mark"),
65+ meta: { align: "right", cellClass: "mono font-semibold" },
6566 cell: (cell) => markWithGrade(cell.row.original.mark, cell.row.original.grade),
6667 },
6768 ]);
src/components/ui/data-table.test.tsxmodified+25 -2
@@ -40,10 +40,33 @@ test("keeps only the rightmost action column sticky", () => {
4040 ));
4141
4242 const actionsHeader = screen.getByRole("columnheader", { name: "Actions" });
43- expect(actionsHeader.classList).toContain("table-sticky-head");
43+ expect(actionsHeader.classList).toContain("table-sticky-head-right");
4444 expect(actionsHeader.classList).toContain("z-30");
4545 const roleHeader = screen.getAllByRole("columnheader").find((header) => header.textContent?.startsWith("Role"));
46- expect(roleHeader?.classList).not.toContain("table-sticky-head");
46+ expect(roleHeader?.classList).not.toContain("table-sticky-head-right");
47+});
48+
49+test("freezes the meta.stickyLeft column and aligns head + cell together", () => {
50+ const alignedColumns: ColumnDef<Row>[] = [
51+ { accessorKey: "name", header: "Name", meta: { stickyLeft: true } },
52+ { accessorKey: "role", header: "Role", meta: { align: "right" } },
53+ ];
54+ render(() => (
55+ <PreferencesProvider>
56+ <DataTable columns={alignedColumns} data={[{ name: "Ada", role: "Admin" }]} enableColumnVisibility={false} enableSorting={false} />
57+ </PreferencesProvider>
58+ ));
59+
60+ const headers = screen.getAllByRole("columnheader");
61+ const nameHeader = headers.find((header) => header.textContent?.startsWith("Name"));
62+ expect(nameHeader?.classList).toContain("table-sticky-head-left");
63+ expect(nameHeader?.classList).toContain("left-0");
64+
65+ const roleHeader = headers.find((header) => header.textContent?.startsWith("Role"));
66+ const roleCell = screen.getByRole("cell", { name: "Admin" });
67+ // Same alignment class on head and cell so columns never drift apart.
68+ expect(roleHeader?.classList).toContain("text-right");
69+ expect(roleCell.classList).toContain("text-right");
4770 });
4871
4972 test("paginates tables by default", () => {
src/components/ui/data-table.tsxmodified+57 -14
@@ -19,7 +19,7 @@ import { Button } from "@/components/ui/button";
1919 import { DataTableSearch } from "@/components/ui/data-table-search";
2020 import { DataTableViewMenu, type ViewMenuColumn } from "@/components/ui/data-table-view-menu";
2121 import { TablePagination } from "@/components/ui/table-pagination";
22-import { IconChevronDown } from "@/components/ui/icons";
22+import { IconArrowDown, IconArrowUp, IconChevronsUpDown } from "@/components/ui/icons";
2323 import { cn } from "@/lib/cn";
2424 import { createTablePreferences } from "@/lib/table-preferences";
2525 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
@@ -30,6 +30,12 @@ declare module "@tanstack/solid-table" {
3030 headerClass?: string;
3131 cellClass?: string;
3232 label?: string;
33+ /** Header + cell horizontal alignment. Applied to both so they never drift apart. */
34+ align?: "left" | "center" | "right";
35+ /** Freeze this column to the left edge on horizontal scroll (fintables-style). */
36+ stickyLeft?: boolean;
37+ /** Vertical divider on the given edge — separates frozen label from metric columns. */
38+ divider?: "left" | "right";
3339 }
3440 }
3541
@@ -70,6 +76,8 @@ export type DataTableProps<TData, TValue = unknown> = {
7076 const resolveUpdater = <T,>(updater: Updater<T>, old: T): T =>
7177 typeof updater === "function" ? (updater as (value: T) => T)(old) : updater;
7278
79+const alignClass = { left: "text-left", center: "text-center", right: "text-right" } as const;
80+
7381 export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, TValue>) {
7482 const t = useT();
7583 const paginationEnabled = props.enablePagination ?? true;
@@ -129,11 +137,27 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
129137 },
130138 });
131139 const hiddenLocked = (columnId: string) => columnId === "actions" || columnId === "update";
132- const stickyLocked = (columnId: string) =>
140+ const stickyRightLocked = (columnId: string) =>
133141 columnId === "actions" || (columnId === "update" && table.getColumn("actions") == null);
134- const actionColumnClass = (columnId: string) => stickyLocked(columnId) ? "w-28 min-w-28 px-2 text-center whitespace-nowrap" : undefined;
135- const stickyHeadClass = (columnId: string) => stickyLocked(columnId) ? "table-sticky-head sticky right-0 z-30" : undefined;
136- const stickyCellClass = (columnId: string) => stickyLocked(columnId) ? "table-sticky-cell sticky right-0 z-10" : undefined;
142+ const isStickyLeft = (column: Column<TData, unknown>) => column.columnDef.meta?.stickyLeft === true;
143+ const alignOf = (column: Column<TData, unknown>) => column.columnDef.meta?.align ?? "left";
144+ const dividerClass = (column: Column<TData, unknown>) => {
145+ const divider = column.columnDef.meta?.divider;
146+ return divider === "left" ? "border-l border-border/70" : divider === "right" ? "border-r border-border/70" : undefined;
147+ };
148+ const actionColumnClass = (columnId: string) => stickyRightLocked(columnId) ? "w-28 min-w-28 px-2 text-center whitespace-nowrap" : undefined;
149+ const stickyHeadClass = (column: Column<TData, unknown>) =>
150+ isStickyLeft(column)
151+ ? "table-sticky-head-left sticky left-0 z-30"
152+ : stickyRightLocked(column.id)
153+ ? "table-sticky-head-right sticky right-0 z-30"
154+ : undefined;
155+ const stickyCellClass = (column: Column<TData, unknown>) =>
156+ isStickyLeft(column)
157+ ? "table-sticky-left sticky left-0 z-10"
158+ : stickyRightLocked(column.id)
159+ ? "table-sticky-right sticky right-0 z-10"
160+ : undefined;
137161 const hideableColumns = () => table.getAllColumns().filter((column) => column.getCanHide() && !hiddenLocked(column.id));
138162 const columnLabel = (column: Column<TData, unknown>) => {
139163 const header = column.columnDef.header;
@@ -149,7 +173,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
149173 const colSpan = () => Math.max(1, table.getVisibleLeafColumns().length);
150174 const tableWidth = () =>
151175 table.getVisibleLeafColumns().reduce(
152- (total, column) => total + (stickyLocked(column.id) ? 112 : column.getSize()),
176+ (total, column) => total + (stickyRightLocked(column.id) ? 112 : column.getSize()),
153177 0,
154178 );
155179 const showColumnMenu = () => (props.enableColumnVisibility ?? true) && hideableColumns().length > 0;
@@ -182,18 +206,33 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
182206 };
183207 const renderHeader = (header: ReturnType<typeof table.getHeaderGroups>[number]["headers"][number]) => {
184208 const content = flexRender(header.column.columnDef.header, header.getContext());
185- if (!(props.enableSorting ?? true) || !header.column.getCanSort()) return content;
209+ const align = alignOf(header.column);
210+ if (!(props.enableSorting ?? true) || !header.column.getCanSort()) {
211+ // The th already carries alignClass; the block span makes text-align resolve.
212+ return <span class="block truncate">{content}</span>;
213+ }
186214 const sorted = () => header.column.getIsSorted();
187215 return (
188216 <Button
189217 type="button"
190218 variant="ghost"
191219 size="sm"
192- class={cn("-ml-3 h-8 px-2 uppercase", sorted() && "text-foreground")}
220+ // th text-align positions this inline-flex button; -ml-3 only trims the left gutter.
221+ class={cn("h-8 px-2 uppercase", align === "left" && "-ml-3", sorted() && "text-foreground")}
193222 onClick={() => header.column.toggleSorting(sorted() === "asc")}
194223 >
195224 {content}
196- <IconChevronDown class={cn("h-3.5 w-3.5 opacity-50", sorted() === "asc" && "rotate-180", sorted() && "opacity-100")} />
225+ <Show
226+ when={sorted() !== false}
227+ fallback={<IconChevronsUpDown class="h-3.5 w-3.5 opacity-50" />}
228+ >
229+ <Show
230+ when={sorted() === "asc"}
231+ fallback={<IconArrowDown class="h-3.5 w-3.5" />}
232+ >
233+ <IconArrowUp class="h-3.5 w-3.5" />
234+ </Show>
235+ </Show>
197236 </Button>
198237 );
199238 };
@@ -257,14 +296,16 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
257296 colSpan={header.colSpan}
258297 class={cn(
259298 "group/head relative",
299+ alignClass[alignOf(header.column)],
300+ dividerClass(header.column),
260301 actionColumnClass(header.column.id),
261- stickyHeadClass(header.column.id),
302+ stickyHeadClass(header.column),
262303 header.column.columnDef.meta?.headerClass,
263304 )}
264- style={{ width: `${stickyLocked(header.column.id) ? 112 : header.getSize()}px` }}
305+ style={{ width: `${stickyRightLocked(header.column.id) ? 112 : header.getSize()}px` }}
265306 >
266307 <Show when={!header.isPlaceholder}>{renderHeader(header)}</Show>
267- <Show when={header.column.getCanResize() && !stickyLocked(header.column.id)}>
308+ <Show when={header.column.getCanResize() && !stickyRightLocked(header.column.id)}>
268309 <div
269310 role="separator"
270311 aria-orientation="vertical"
@@ -333,11 +374,13 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
333374 {(cell) => (
334375 <TableCell
335376 class={cn(
377+ alignClass[alignOf(cell.column)],
378+ dividerClass(cell.column),
336379 actionColumnClass(cell.column.id),
337- stickyCellClass(cell.column.id),
380+ stickyCellClass(cell.column),
338381 cell.column.columnDef.meta?.cellClass,
339382 )}
340- style={{ width: `${stickyLocked(cell.column.id) ? 112 : cell.column.getSize()}px` }}
383+ style={{ width: `${stickyRightLocked(cell.column.id) ? 112 : cell.column.getSize()}px` }}
341384 >
342385 {flexRender(cell.column.columnDef.cell, cell.getContext())}
343386 </TableCell>
src/components/ui/icons.tsxmodified+27 -0
@@ -345,6 +345,33 @@ export function IconChevronDown(props: IconProps) {
345345 );
346346 }
347347
348+export function IconArrowUp(props: IconProps) {
349+ return (
350+ <Svg {...props}>
351+ <path d="M12 19V5" />
352+ <path d="m5 12 7-7 7 7" />
353+ </Svg>
354+ );
355+}
356+
357+export function IconArrowDown(props: IconProps) {
358+ return (
359+ <Svg {...props}>
360+ <path d="M12 5v14" />
361+ <path d="m19 12-7 7-7-7" />
362+ </Svg>
363+ );
364+}
365+
366+export function IconChevronsUpDown(props: IconProps) {
367+ return (
368+ <Svg {...props}>
369+ <path d="m7 15 5 5 5-5" />
370+ <path d="m7 9 5-5 5 5" />
371+ </Svg>
372+ );
373+}
374+
348375 export function IconHome(props: IconProps) {
349376 return (
350377 <Svg {...props}>
src/components/ui/table-pagination.tsxmodified+6 -1
@@ -18,7 +18,12 @@ export type TablePaginationProps = {
1818 /** Footer: "X kayıttan a-b arası" + page-size select + prev/next + "page / total". */
1919 export function TablePagination(props: TablePaginationProps) {
2020 const t = useT();
21- const options = () => props.pageSizeOptions ?? [10, 25, 50];
21+ // Always include the active page size so the select shows a selected value
22+ // instead of rendering blank when a page passes a non-standard size (e.g. 12).
23+ const options = () => {
24+ const base = props.pageSizeOptions ?? [10, 25, 50];
25+ return base.includes(props.pageSize) ? base : [...base, props.pageSize].sort((a, b) => a - b);
26+ };
2227 const start = () => (props.total === 0 ? 0 : props.pageIndex * props.pageSize + 1);
2328 const end = () => Math.min((props.pageIndex + 1) * props.pageSize, props.total);
2429
src/index.cssmodified+27 -6
@@ -141,7 +141,10 @@
141141 }
142142
143143 & th {
144- @apply h-11 overflow-hidden text-ellipsis whitespace-nowrap px-3 text-left text-[11px] font-bold uppercase tracking-[0.16em] text-muted-foreground first:pl-4 last:pr-4;
144+ /* No text-align here: `.data-table th` would out-specify the per-column
145+ * text-right/center utility on TableHead and force every header left. The
146+ * TableHead base class provides the left default; alignment stays utility-driven. */
147+ @apply h-11 overflow-hidden text-ellipsis whitespace-nowrap px-3 text-[11px] font-bold uppercase tracking-[0.16em] text-muted-foreground first:pl-4 last:pr-4;
145148 background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));
146149 }
147150
@@ -172,16 +175,34 @@
172175 }
173176
174177 /*
175- * Yatay kaydırmada sağda sabit kalan aksiyon hücresi. Altındaki içerik görünmesin
176- * diye opak olmalı ama zebra/hover satır tonuyla da eşleşmeli: yarı saydam satır
177- * tonunun kart zemini üzerindeki karşılığı color-mix ile üretiliyor.
178+ * Yatay kaydırmada sabit kalan (dondurulmuş) kolonlar. Altındaki içerik görünmesin
179+ * diye opak olmalı ama zebra/hover satır tonuyla da eşleşmeli: gövde hücresi satır
180+ * tonunu `inherit` ile alır, başlık hücresi başlık tonunu kullanır. Kayan içerikle
181+ * arasında görsel dikiş için kenara ince çizgi + yumuşak gölge eklenir.
178182 */
179-@utility table-sticky-cell {
183+@utility table-sticky-left {
180184 background-color: inherit;
185+ border-right: 1px solid hsl(var(--border));
186+ box-shadow: 6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
181187 }
182188
183-@utility table-sticky-head {
189+@utility table-sticky-right {
190+ background-color: inherit;
191+ border-left: 1px solid hsl(var(--border));
192+ box-shadow: -6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
193+}
194+
195+/* Dondurulmuş başlık hücreleri gövde hücrelerinin üstünde opak kalmalı. */
196+@utility table-sticky-head-left {
197+ background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));
198+ border-right: 1px solid hsl(var(--border));
199+ box-shadow: 6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
200+}
201+
202+@utility table-sticky-head-right {
184203 background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));
204+ border-left: 1px solid hsl(var(--border));
205+ box-shadow: -6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
185206 }
186207
187208 /* Satır yoğunluğu (density). Normal = @utility data-table varsayılanları. */
src/pages/courses-page.tsxmodified+1 -1
@@ -28,7 +28,7 @@ import { hasMinRole } from "@/lib/roles";
2828 import { useAuth } from "@/stores/auth-context";
2929 import { useT } from "@/stores/preferences-context";
3030
31-const PAGE_SIZE = 12;
31+const PAGE_SIZE = 10;
3232
3333 export default function CoursesPage() {
3434 return <RouteGuard><CoursesContent /></RouteGuard>;
src/pages/exams-page.tsxmodified+1 -1
@@ -32,7 +32,7 @@ import { cn } from "@/lib/cn";
3232 import { useAuth } from "@/stores/auth-context";
3333 import { usePreferences, useT } from "@/stores/preferences-context";
3434
35-const EXAM_PAGE_SIZE = 12;
35+const EXAM_PAGE_SIZE = 10;
3636
3737 type ExamRow = Exam & { displayStatus: ExamDisplayStatus };
3838
src/pages/homework-page.tsxmodified+1 -1
@@ -243,7 +243,7 @@ function HomeworkContent() {
243243 tableClass="table-fixed min-w-5xl"
244244 filterColumn="title"
245245 enablePagination
246- pageSize={12}
246+ pageSize={10}
247247 empty={t("homework.empty")}
248248 storageKey="homework"
249249 onRowClick={(item) => void navigate({ to: "/homework/$id", params: { id: item.id } })}
src/pages/meals-page.tsxmodified+1 -1
@@ -22,7 +22,7 @@ import { hasMinRole } from "@/lib/roles";
2222 import { useAuth } from "@/stores/auth-context";
2323 import { usePreferences, useT } from "@/stores/preferences-context";
2424
25-const PAGE_SIZE = 12;
25+const PAGE_SIZE = 10;
2626 const today = () => new Date().toISOString().slice(0, 10);
2727
2828 export default function MealsPage() {
src/pages/my-students-page.tsxmodified+4 -4
@@ -132,14 +132,14 @@ function StudentDetailPanel(props: { student: PersonRef | null; onClose: () => v
132132 },
133133 {
134134 accessorKey: "weight",
135- header: () => <span class="block text-right">{t("marks.weight")}</span>,
136- meta: { cellClass: "mono text-right tabular-nums" },
135+ header: t("marks.weight"),
136+ meta: { align: "right", cellClass: "mono tabular-nums" },
137137 cell: (cell) => cell.row.original.weight,
138138 },
139139 {
140140 accessorKey: "mark",
141- header: () => <span class="block text-right">{t("marks.mark")}</span>,
142- meta: { cellClass: "mono text-right font-semibold tabular-nums" },
141+ header: t("marks.mark"),
142+ meta: { align: "right", cellClass: "mono font-semibold tabular-nums" },
143143 cell: (cell) => formatNumber(cell.row.original.mark),
144144 },
145145 ]);
src/pages/notes-page.tsxmodified+1 -1
@@ -21,7 +21,7 @@ import { createFlash } from "@/lib/flash";
2121 import { loadListPage, totalPages as pagesOf } from "@/lib/list-page";
2222 import { useT } from "@/stores/preferences-context";
2323
24-const NOTE_PAGE_SIZE = 12;
24+const NOTE_PAGE_SIZE = 10;
2525
2626 export default function NotesPage() {
2727 return (
src/pages/payment-statement-page.tsxmodified+1 -1
@@ -28,7 +28,7 @@ import { personLabel } from "@/lib/person";
2828 import { useAuth } from "@/stores/auth-context";
2929 import { usePreferences, useT } from "@/stores/preferences-context";
3030
31-const STATEMENT_PAGE_SIZE = 12;
31+const STATEMENT_PAGE_SIZE = 10;
3232
3333 export default function PaymentStatementPage() {
3434 return (
src/pages/payments-page.tsxmodified+1 -1
@@ -48,7 +48,7 @@ import { PAYMENT_METHOD_KEYS, sortStatementEntries, statementStatus } from "@/li
4848 import { personLabel } from "@/lib/person";
4949 import { usePreferences, useT } from "@/stores/preferences-context";
5050
51-const PLAN_PAGE_SIZE = 12;
51+const PLAN_PAGE_SIZE = 10;
5252 const STATEMENT_PAGE_SIZE = 15;
5353 const STUDENT_PAGE_SIZE = 10;
5454
src/pages/question-bank-page.tsxmodified+1 -1
@@ -22,7 +22,7 @@ import { hasMinRole } from "@/lib/roles";
2222 import { useAuth } from "@/stores/auth-context";
2323 import { useT } from "@/stores/preferences-context";
2424
25-const BANK_PAGE_SIZE = 12;
25+const BANK_PAGE_SIZE = 10;
2626
2727 export default function QuestionBankPage() {
2828 return (
src/pages/staff-work-page.tsxmodified+1 -1
@@ -24,7 +24,7 @@ import { formatDateTime, formatDurationMinutes } from "@/lib/format";
2424 import { personLabel } from "@/lib/person";
2525 import { usePreferences, useT } from "@/stores/preferences-context";
2626
27-const PEOPLE_PAGE_SIZE = 12;
27+const PEOPLE_PAGE_SIZE = 10;
2828 const WORK_PAGE_SIZE = 15;
2929 function msToDateInput(ms: number): string {
3030 const d = new Date(ms);
src/pages/student-attendance-page.tsxmodified+1 -1
@@ -15,7 +15,7 @@ import { TableRowActions } from "@/components/ui/table-row-actions";
1515 import { personLabel } from "@/lib/person";
1616 import { useT } from "@/stores/preferences-context";
1717
18-const PAGE_SIZE = 12;
18+const PAGE_SIZE = 10;
1919
2020 export default function StudentAttendancePage() {
2121 return (
src/pages/student-marks-page.tsxmodified+12 -4
@@ -16,7 +16,7 @@ import { TableRowActions } from "@/components/ui/table-row-actions";
1616 import { personLabel } from "@/lib/person";
1717 import { useT } from "@/stores/preferences-context";
1818
19-const PAGE_SIZE = 12;
19+const PAGE_SIZE = 10;
2020 const round = (n: number) => (Math.round(n * 100) / 100).toString();
2121 // ponytail: display-only color tiers (70/40 on a 0-100 scale), not a pass/fail rule
2222 const avgTone = (v: number) =>
@@ -91,7 +91,15 @@ function StudentMarksContent() {
9191 );
9292
9393 const total = () => list().length;
94- const rows = () => list();
94+ // The inline "average" column reads the separate marksMapRes resource, which
95+ // resolves AFTER this table first renders. TanStack caches cell values by the
96+ // data-array identity, so without a new reference the averages only appear once
97+ // something forces a re-derive (e.g. sorting). Track marksMapRes and hand back a
98+ // fresh array so the column fills in as soon as the marks load.
99+ const rows = () => {
100+ marksMapRes();
101+ return [...list()];
102+ };
95103 const listLoading = () => list.loading;
96104 const searchPerson = (person: PersonRef, query: string) =>
97105 [person.username, person.display_name, person.id].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase());
@@ -108,9 +116,9 @@ function StudentMarksContent() {
108116 },
109117 {
110118 id: "average",
111- header: () => <span class="block text-right">{t("marks.overall")}</span>,
119+ header: t("marks.overall"),
112120 accessorFn: (user) => marksOf(user.id)?.overall_average ?? -1,
113- meta: { headerClass: "text-right", cellClass: "text-right" },
121+ meta: { align: "right" },
114122 cell: (cell) => {
115123 const rep = marksOf(cell.row.original.id);
116124 if (rep == null) return <span class="text-sm text-muted-foreground">—</span>;
src/pages/student-pomodoro-page.tsxmodified+1 -1
@@ -15,7 +15,7 @@ import { formatDateTime, formatDurationClock } from "@/lib/format";
1515 import { personLabel } from "@/lib/person";
1616 import { usePreferences, useT } from "@/stores/preferences-context";
1717
18-const PAGE_SIZE = 12;
18+const PAGE_SIZE = 10;
1919
2020 export default function StudentPomodoroPage() {
2121 return (
src/pages/terms-page.tsxmodified+1 -1
@@ -24,7 +24,7 @@ import { createFlash } from "@/lib/flash";
2424 import { formatDateTime } from "@/lib/format";
2525 import { usePreferences, useT } from "@/stores/preferences-context";
2626
27-const TERM_PAGE_SIZE = 12;
27+const TERM_PAGE_SIZE = 10;
2828
2929 function dateInputFromMs(ms: number): string {
3030 const date = new Date(ms);