diff --git a/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts b/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts index 217f1462e..7d64e516a 100644 --- a/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts +++ b/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts @@ -202,16 +202,16 @@ export class DbTableViewComponent implements OnInit, OnChanges { ); if (!loading && this.tableData.defaultSort !== undefined) { - // Update defaultSort reference whenever data loads - this.defaultSort = this.tableData.defaultSort; - console.log('DbTableViewComponent tableData loaded:', this.tableData); console.log('DbTableViewComponent tableData.defaultSort loaded:', this.tableData.defaultSort); - // Only initialize sort on first load (or after table switch when sortInitialized was reset) + // Only initialize sort and defaultSort on first load (or after table switch when sortInitialized was reset) if (!this.sortInitialized) { this.sortInitialized = true; + // Only sync defaultSort from server on initial load, not on subsequent sort/pagination changes + this.defaultSort = this.tableData.defaultSort; + // Initialize sort based on priority: URL params > default sort if (urlSortActive && urlSortDirection) { // Use sort from URL @@ -266,6 +266,9 @@ export class DbTableViewComponent implements OnInit, OnChanges { this.sort.active = ''; this.sort.direction = '' as any; + // Reset defaultSort so the previous table's default doesn't show on the new table + this.defaultSort = null; + // Reset the sortInitialized flag so the sort gets re-initialized with new table's default sort this.sortInitialized = false; }