Description
KuadrantDataView stores the active sort column by index in state. When the columns array changes (e.g., inserting a "Namespace" column in MyAPIKeysPage when switching to all-namespaces mode), the stored index points to the wrong column.
Current Behaviour
- User sorts by "Status" (column at index 3)
- User switches to all-namespaces view
- Namespace column is inserted at index 1
- "Status" is now at index 4
sortBy.index still has 3, pointing to wrong column
- Wrong column appears sorted
Expected Behaviour
Store the column ID instead of index, then derive the index from the current columns array on each render:
const [sortState, setSortState] = useState(() => getInitialSortState(columns));
const sortIndex = columns.findIndex((column) => column.id === sortState.id);
const sortBy: ISortBy = sortIndex >= 0 ? { index: sortIndex, direction: sortState.direction } : {};
Location
src/components/KuadrantDataView.tsx:170
Related
CodeRabbit comment in PR #734
Description
KuadrantDataViewstores the active sort column by index in state. When the columns array changes (e.g., inserting a "Namespace" column in MyAPIKeysPage when switching to all-namespaces mode), the stored index points to the wrong column.Current Behaviour
sortBy.indexstill has3, pointing to wrong columnExpected Behaviour
Store the column ID instead of index, then derive the index from the current columns array on each render:
Location
src/components/KuadrantDataView.tsx:170Related
CodeRabbit comment in PR #734