Skip to content

Commit edf8615

Browse files
committed
Fixed sorting for plugin tables that have raw numbers
1 parent eac25b5 commit edf8615

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Plan/react/dashboard/src/components/table/DataTablesTable.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ const DataTablesTable = ({id, rowKeyFunction, options, colorClass}) => {
123123
if (valA === undefined && valB === undefined) return 0;
124124
if (valA === undefined) return sortReversed ? 1 : -1;
125125
if (valB === undefined) return sortReversed ? 1 : -1;
126-
if (typeof valA === 'number' && typeof valB === 'number') {
126+
const isNumberA = typeof valA === 'number' || !isNaN(valA);
127+
const isNumberB = typeof valB === 'number' || !isNaN(valB);
128+
if (isNumberA && isNumberB) {
127129
return sortReversed ? valA - valB : valB - valA;
128130
}
129131
return sortReversed ? valB.localeCompare(valA) : valA.localeCompare(valB);
@@ -269,7 +271,8 @@ const DataTablesTable = ({id, rowKeyFunction, options, colorClass}) => {
269271
</React.Fragment>)}
270272
</tbody>
271273
</table>
272-
<p className={"dataTables_info float-start"} style={{maxWidth: "40%", textOverflow: "ellipsis", whiteSpace: "nowrap"}}>
274+
<p className={"dataTables_info float-start"}
275+
style={{maxWidth: "40%", textOverflow: "ellipsis", whiteSpace: "nowrap"}}>
273276
<Trans i18nKey={"html.label.table.showNofM"}
274277
defaults={"Showing {{n}} of {{m}} entries"}
275278
values={{

0 commit comments

Comments
 (0)