From 66561e1d8ecd1c5b31a15abf433c8a7a2e3032f3 Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Tue, 23 Aug 2016 11:23:30 +0200 Subject: [PATCH] Sort non-number columns ASCending by default. - And number columns DESCending by default. - default: when you sort by that column for the first time. --- .../scripts/components/node-details/node-details-table.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/app/scripts/components/node-details/node-details-table.js b/client/app/scripts/components/node-details/node-details-table.js index 31db1870f..a87b4c0d1 100644 --- a/client/app/scripts/components/node-details/node-details-table.js +++ b/client/app/scripts/components/node-details/node-details-table.js @@ -163,9 +163,11 @@ export default class NodeDetailsTable extends React.Component { handleHeaderClick(ev, headerId) { ev.preventDefault(); - const sortedDesc = headerId === this.state.sortBy - ? !this.state.sortedDesc : this.state.sortedDesc; - const sortBy = headerId; + const header = this.getColumnHeaders().find(h => h.id === headerId); + const defaultSortDesc = header.dataType === 'number'; + const sortedDesc = header.id === this.state.sortBy + ? !this.state.sortedDesc : defaultSortDesc; + const sortBy = header.id; this.setState({sortBy, sortedDesc}); this.props.onSortChange(sortBy, sortedDesc); }