Skip to content

Commit

Permalink
#239 Remove sorting arrow icon when canSort prop is set to false in D…
Browse files Browse the repository at this point in the history
…ataTable component
  • Loading branch information
LukaFilipovic99 committed Apr 24, 2024
1 parent f9bfdaf commit 4f95b25
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions libs/data-display/src/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ function DataTable<T extends object>({
className={tableHeaderClassName}
title={column.title}
onClick={() => {
toggleSortBy(column.id, undefined, multiSort);
if (column.canSort) {
toggleSortBy(column.id, undefined, multiSort);
}
}}
>
<DataTableHeader alignHeader={alignHeader} {...column}>
Expand Down Expand Up @@ -815,10 +817,11 @@ function DataTableHeader({
return (
<div className={tableHeaderContainer}>
{children}

<span className="flex justify-center items-center ml-1">
{isSorted ? isSortedDesc ? sortDescIcon : sortAscIcon : canSort ? <div className="w-4 h-4">&nbsp;</div> : null}
</span>
{canSort && (
<span className="flex justify-center items-center ml-1">
{isSorted ? isSortedDesc ? sortDescIcon : sortAscIcon : <div className="w-3.5">&nbsp;</div>}
</span>
)}
</div>
);
}
Expand Down Expand Up @@ -1081,6 +1084,7 @@ function DataTableColumn<T extends object>(_: DataTableColumnProps<T>) {

DataTableColumn.defaultProps = {
type: "DataTableColumn",
canSort: false,
};

function DataTableExpander<T>(_: DataTableExpanderProps<T>) {
Expand Down

0 comments on commit 4f95b25

Please sign in to comment.