From 4f95b258fff55f779fa1f73ee43d16ab781f0932 Mon Sep 17 00:00:00 2001 From: Luka Date: Wed, 24 Apr 2024 11:45:21 +0200 Subject: [PATCH] #239 Remove sorting arrow icon when canSort prop is set to false in DataTable component --- libs/data-display/src/DataTable.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libs/data-display/src/DataTable.tsx b/libs/data-display/src/DataTable.tsx index e119ada..8052703 100644 --- a/libs/data-display/src/DataTable.tsx +++ b/libs/data-display/src/DataTable.tsx @@ -646,7 +646,9 @@ function DataTable({ className={tableHeaderClassName} title={column.title} onClick={() => { - toggleSortBy(column.id, undefined, multiSort); + if (column.canSort) { + toggleSortBy(column.id, undefined, multiSort); + } }} > @@ -815,10 +817,11 @@ function DataTableHeader({ return (
{children} - - - {isSorted ? isSortedDesc ? sortDescIcon : sortAscIcon : canSort ?
 
: null} -
+ {canSort && ( + + {isSorted ? isSortedDesc ? sortDescIcon : sortAscIcon :
 
} +
+ )}
); } @@ -1081,6 +1084,7 @@ function DataTableColumn(_: DataTableColumnProps) { DataTableColumn.defaultProps = { type: "DataTableColumn", + canSort: false, }; function DataTableExpander(_: DataTableExpanderProps) {