Skip to content

Commit

Permalink
Fixed sorting for plugin tables that have raw numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraLS3 committed Oct 21, 2023
1 parent eac25b5 commit edf8615
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Plan/react/dashboard/src/components/table/DataTablesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ const DataTablesTable = ({id, rowKeyFunction, options, colorClass}) => {
if (valA === undefined && valB === undefined) return 0;
if (valA === undefined) return sortReversed ? 1 : -1;
if (valB === undefined) return sortReversed ? 1 : -1;
if (typeof valA === 'number' && typeof valB === 'number') {
const isNumberA = typeof valA === 'number' || !isNaN(valA);
const isNumberB = typeof valB === 'number' || !isNaN(valB);
if (isNumberA && isNumberB) {
return sortReversed ? valA - valB : valB - valA;
}
return sortReversed ? valB.localeCompare(valA) : valA.localeCompare(valB);
Expand Down Expand Up @@ -269,7 +271,8 @@ const DataTablesTable = ({id, rowKeyFunction, options, colorClass}) => {
</React.Fragment>)}
</tbody>
</table>
<p className={"dataTables_info float-start"} style={{maxWidth: "40%", textOverflow: "ellipsis", whiteSpace: "nowrap"}}>
<p className={"dataTables_info float-start"}
style={{maxWidth: "40%", textOverflow: "ellipsis", whiteSpace: "nowrap"}}>
<Trans i18nKey={"html.label.table.showNofM"}
defaults={"Showing {{n}} of {{m}} entries"}
values={{
Expand Down

0 comments on commit edf8615

Please sign in to comment.