Skip to content

feat: default sort config for tables in canvas#9648

Open
djbarnwal wants to merge 4 commits into
mainfrom
feat/default-sort-pivot-canvas
Open

feat: default sort config for tables in canvas#9648
djbarnwal wants to merge 4 commits into
mainfrom
feat/default-sort-pivot-canvas

Conversation

@djbarnwal

Copy link
Copy Markdown
Member

Adds support for default sort order configuration for pivot and flat tables in canvas dashboard

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@djbarnwal djbarnwal requested a review from nishantmonu51 July 5, 2026 07:12
@nishantmonu51 nishantmonu51 added Type:Feature New feature request Area:Pivot Size:M Medium change: 100-499 lines labels Jul 6, 2026
@djbarnwal djbarnwal requested a review from AdityaHegde July 9, 2026 11:21
@nishantmonu51

Copy link
Copy Markdown
Collaborator

@codex: review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c02a354952

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


let defaultSorting: SortingState;
$: defaultSorting = tableSpec.default_sort
? [{ id: tableSpec.default_sort.id, desc: tableSpec.default_sort.desc }]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate default_sort before reapplying it

When a saved default sort points at a field that is no longer part of the current table (for example, set the default on sales, then remove sales from measures/columns or change the metrics view), this always rehydrates that stale id into pivotState.sorting. For nested pivots, getSortForAccessor only treats ids in the current measureNames or row dimension as stable; a stale stable id falls through to nested-accessor parsing and can index columnDimensionAxes[undefined][NaN], crashing the table, while flat tables send a sort for a non-selected field. Please clear or validate default_sort against the current fields before applying it.

Useful? React with 👍 / 👎.

function makeDefault() {
if (!activeSort) return;
component.updateProperty("default_sort", {
id: activeSort.id,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't persist position-based nested sort ids

For nested pivot leaf columns, activeSort.id is an accessor like c0v2m0, where v2 is only the current index in columnDimensionAxes. Saving that raw id as a default means the same YAML can sort by a different column value whenever filters, time range, or data change the column-axis ordering (or by undefined if the index disappears); the human label stored here is not used when applying the default. Store stable column-dimension values or invalidate nested defaults when axes change instead of persisting the positional accessor.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area:Pivot Size:M Medium change: 100-499 lines Type:Feature New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants