Skip to content

Commit

Permalink
Fix: RenderSortButton renders content correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Domino987 committed Jan 29, 2022
1 parent 3e93e91 commit 5faa47c
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/components/MTableHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ export function MTableHeader({ onColumnResized, ...props }) {
: { position: 'relative', minWidth: 0, display: 'flex' }
}
>
{columnDef.title}
{columnDef.sorting !== false && props.sorting && (
<RenderSortButton
columnDef={columnDef}
Expand All @@ -235,28 +234,29 @@ export function MTableHeader({ onColumnResized, ...props }) {
icon={props.icons.SortArrow}
thirdSortClick={props.thirdSortClick}
onOrderChange={props.onOrderChange}
/>
>
{columnDef.title}
</RenderSortButton>
)}
</div>
)}
</Draggable>
);
} else if (columnDef.sorting !== false && props.sorting) {
content = (
<>
<RenderSortButton
columnDef={columnDef}
orderBy={props.orderBy}
keepSortDirectionOnColumnSwitch={
props.keepSortDirectionOnColumnSwitch
}
orderDirection={props.orderDirection}
icon={props.icons.SortArrow}
thirdSortClick={props.thirdSortClick}
onOrderChange={props.onOrderChange}
>
{columnDef.title}
<RenderSortButton
columnDef={columnDef}
orderBy={props.orderBy}
keepSortDirectionOnColumnSwitch={
props.keepSortDirectionOnColumnSwitch
}
orderDirection={props.orderDirection}
icon={props.icons.SortArrow}
thirdSortClick={props.thirdSortClick}
onOrderChange={props.onOrderChange}
/>
</>
</RenderSortButton>
);
}
if (columnDef.tooltip) {
Expand Down Expand Up @@ -454,7 +454,8 @@ function RenderSortButton({
orderDirection,
icon,
thirdSortClick,
onOrderChange
onOrderChange,
children
}) {
const active = orderBy === columnDef.tableData.id;
// If current sorted column or prop asked to
Expand Down Expand Up @@ -491,7 +492,9 @@ function RenderSortButton({
);
onOrderChange(columnDef.tableData.id, newOrderDirection);
}}
/>
>
{children}
</TableSortLabel>
);
}

Expand Down

0 comments on commit 5faa47c

Please sign in to comment.