@@ -49,8 +49,8 @@ const gadgetToPolarisDirection = (direction?: SortOrder) => {
4949 return undefined ;
5050} ;
5151
52- const getColumnIndex = ( columns : TableColumn [ ] , apiIdentifier : string | undefined ) => {
53- return columns . findIndex ( ( column ) => column . field === apiIdentifier ) ;
52+ const maybeGetColumnIndex = ( columns : TableColumn [ ] , apiIdentifier : string | undefined ) => {
53+ return columns . findIndex ( ( column ) => ( column . type === "CustomRenderer" ? undefined : column . field === apiIdentifier ) ) ;
5454} ;
5555
5656export type PolarisAutoTableProps <
@@ -127,8 +127,11 @@ const PolarisAutoTableComponent = <
127127
128128 const handleColumnSort = ( headingIndex : number ) => {
129129 if ( columns ) {
130- const columnApiIdentifier = columns [ headingIndex ] . field ;
131- sort . handleColumnSort ( columnApiIdentifier ) ;
130+ const currentColumn = columns [ headingIndex ] ;
131+ const columnApiIdentifier = currentColumn . type === "CustomRenderer" ? undefined : currentColumn . field ;
132+ if ( columnApiIdentifier ) {
133+ sort . handleColumnSort ( columnApiIdentifier ) ;
134+ }
132135 }
133136 } ;
134137
@@ -147,7 +150,9 @@ const PolarisAutoTableComponent = <
147150
148151 if ( columns ) {
149152 for ( const column of columns ) {
150- headings . push ( { title : column . header } ) ;
153+ headings . push ( {
154+ title : column . header as string , // Polaris type says that this must be a string, but this works with a ReactNode
155+ } ) ;
151156 sortable . push ( column . sortable ) ;
152157 }
153158 }
@@ -247,7 +252,7 @@ const PolarisAutoTableComponent = <
247252 : undefined
248253 }
249254 sortDirection = { gadgetToPolarisDirection ( sort . direction ) }
250- sortColumnIndex = { columns ? getColumnIndex ( columns , sort . column ) : undefined }
255+ sortColumnIndex = { columns ? maybeGetColumnIndex ( columns , sort . column ) : undefined }
251256 onSort = { ( headingIndex ) => handleColumnSort ( headingIndex ) }
252257 selectable = { props . selectable === undefined ? bulkActionOptions . length !== 0 : props . selectable }
253258 lastColumnSticky = { props . lastColumnSticky }
0 commit comments