@@ -43,8 +43,6 @@ import { fallbackData, templatesTableConfig, useColumns } from './table-config'
4343
4444const COLUMN_TO_SORT_BASE : Record < string , string > = {
4545 name : 'name' ,
46- cpuCount : 'cpu_count' ,
47- memoryMB : 'memory_mb' ,
4846 createdAt : 'created_at' ,
4947 updatedAt : 'updated_at' ,
5048}
@@ -59,8 +57,14 @@ export default function TemplatesTable() {
5957 useTemplateTableStore ( )
6058 const { cpuCount, memoryMB, isPublic } = useTemplateTableStore ( )
6159
60+ // Persisted state (URL hash) may still reference columns that are no longer sortable.
61+ const activeSorting = useMemo (
62+ ( ) => sorting . filter ( ( s ) => s . id in COLUMN_TO_SORT_BASE ) ,
63+ [ sorting ]
64+ )
65+
6266 // Derive the single server sort token from the active sort column + direction.
63- const sortColumn = sorting [ 0 ]
67+ const sortColumn = activeSorting [ 0 ]
6468 const sortBase =
6569 ( sortColumn && COLUMN_TO_SORT_BASE [ sortColumn . id ] ) ??
6670 TEMPLATES_DEFAULT_SORT_BASE
@@ -135,7 +139,7 @@ export default function TemplatesTable() {
135139 columns : columns ?? fallbackData ,
136140 state : {
137141 globalFilter,
138- sorting,
142+ sorting : activeSorting ,
139143 columnSizing,
140144 } ,
141145 onGlobalFilterChange : setGlobalFilter ,
@@ -190,7 +194,9 @@ export default function TemplatesTable() {
190194 < DataTableHead
191195 key = { header . id }
192196 header = { header }
193- sorting = { sorting . find ( ( s ) => s . id === header . id ) ?. desc }
197+ sorting = {
198+ activeSorting . find ( ( s ) => s . id === header . id ) ?. desc
199+ }
194200 align = {
195201 header . id === 'cpuCount' ||
196202 header . id === 'memoryMB' ||
0 commit comments