Skip to content

Auto-derived related lists have no default-sort surface — derivation emits no sort, component skips $orderby, rows fall to PK order #5795

Description

@baozhoutao

Environment

  • Platform: @objectstack/*@17.2.0 (@objectstack/console@17.2.0, @objectstack/spec@17.2.0)
  • Surface: record detail page → auto-derived related list tab (master-detail child object)

Phenomenon

An auto-derived related list has no way to declare a default sort. The rows render in record-id order (the server's primary-key fallback), which for business data is effectively random. Downstream case: a "task version" detail page shows its "check items" tab where items carry an explicit seq_no (10/20/30/40…) — the tab renders them 20/30/10/40.

Root cause (verified against 17.2.0 dist)

  1. The console's related-list derivation produces columns / title / summary for the tab, but never produces sort;
  2. The related-list component only appends $orderby to the query when it is handed a sort — so the derived list's query goes out without $orderby and falls to the PK order;
  3. There is no declaration surface anywhere to fill the gap:
    • the field-level relatedList* keys (relatedList, relatedListTitle, relatedListColumns, relatedListFilter) have no sort key, and the schema is $strict — adding one is rejected;
    • the child object's own list view sort is not consulted by the derivation (verified: child default view sorted by seq_no, related list still id-order);
    • view.form.defaultSort was removed in 17.0.0.

Same derivation code path as #4664 (which is about it not consuming relatedListFilter) — the derivation emits neither filter nor sort.

Repro

  1. Master object A, child object B (master_detail lookup to A) with a number field seq_no;
  2. Create 4 B-records under one A in shuffled order so seq_no = 20/30/10/40 by creation sequence;
  3. Open A's record page → B tab: rows show 20/30/10/40 (id order), not 10/20/30/40;
  4. Set B's default list view sort: [{field:'seq_no', order:'asc'}] → B's own list obeys it, the related list tab does not; network shows the related-list request carries no $orderby.

Ask (either)

  1. Field-level relatedListSort next to the existing relatedList* keys (mirroring how Auto-derived related lists consume the new field-level relatedListFilter declaration — list query AND-composed, tab badge honors the same filter #4664 asks relatedListFilter to be consumed), or
  2. Let the derivation inherit the child object's default list view sort.

Either way the related-list query should carry $orderby, and pagination (if any) should respect it.

Blocked-by: objectstack-ai/objectstack#11345


Generated by Claude Code

Metadata

Metadata

Assignees

Labels

domain:uiobjectui ui stream: fix lands on the published library or apps — objectui execution seatpm:dispatched

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions