rusackas commented on code in PR #44208:
URL: https://github.com/apache/superset/pull/44208#discussion_r4172379802


##########
superset-frontend/packages/superset-ui-core/src/components/TableCollection/utils.tsx:
##########
@@ -84,35 +90,49 @@ function getSortingInfo<T extends object>(
 }
 
 export function mapColumns<T extends object>(
-  columns: EnhancedColumnInstance<T>[],
-  headerGroups: EnhancedHeaderGroup<T>[],
+  columns: ListViewColumn<T>[],
+  headerGroups: HeaderGroup<T>[],
   columnsForWrapText?: string[],
 ) {
   return columns.map(column => {
-    const { isSorted, isSortedDesc } = getSortingInfo(headerGroups, column.id);
+    // react-table backfills `id` from a string `accessor` for its own
+    // internal column instances, but callers routinely author raw column
+    // configs (the shape this function actually receives, per
+    // `ListViewColumn`) with only `accessor` set. Falling back to it here
+    // keeps every column's antd `key`/`dataIndex` unique; without it,
+    // id-less columns all collapse onto the same (undefined) key and antd
+    // can't tell them apart for sorting.
+    const id =
+      column.id ??
+      (typeof column.accessor === 'string' ? column.accessor : undefined) ??
+      '';
+    const { isSorted, isSortedDesc } = getSortingInfo(headerGroups, id);
     return {

Review Comment:
   Good catch, @sadpandajoe. The id fallback made that column sortable. I 
disabled sorting on the `User` column in Action Log (`disableSortBy`), since 
the Log API only orders by scalar fields.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to