@@ -25,9 +25,9 @@ import {
25
25
DATA_TABLE_COLUMN ,
26
26
} from '../../../utilities/constants' ;
27
27
28
- const defaultProps = {
29
- firstSortDirection : 'asc'
30
- } ;
28
+ // const defaultProps = {
29
+ // firstSortDirection: 'asc'
30
+ // };
31
31
32
32
/**
33
33
* Used internally, renders each individual column heading.
@@ -84,7 +84,7 @@ class DataTableHeaderCell extends React.Component {
84
84
width : PropTypes . string ,
85
85
} ;
86
86
87
- static defaultProps = defaultProps ;
87
+ // static defaultProps = defaultProps;
88
88
89
89
state = {
90
90
sortDirection : null ,
@@ -104,10 +104,16 @@ class DataTableHeaderCell extends React.Component {
104
104
handleSort = ( e ) => {
105
105
const oldSortDirection =
106
106
this . props . sortDirection || this . state . sortDirection ;
107
- var sortDirection = this . props . firstSortDirection
108
- if ( oldSortDirection ) {
109
- sortDirection = oldSortDirection === 'asc' ? 'desc' : 'asc'
110
- }
107
+ const sortDirection = ( function ( sortDirection , firstDirection ) {
108
+ switch ( sortDirection ) {
109
+ case 'asc' :
110
+ return 'desc'
111
+ case 'desc' :
112
+ return 'asc'
113
+ case null :
114
+ return ( firstDirection ) ? firstDirection : 'asc'
115
+ }
116
+ } ) ( oldSortDirection , this . props . firstSortDirection )
111
117
const data = {
112
118
property : this . props . property ,
113
119
sortDirection,
@@ -127,7 +133,8 @@ class DataTableHeaderCell extends React.Component {
127
133
const { fixedHeader, isSorted, label, sortable, width } = this . props ;
128
134
129
135
const labelType = typeof label ;
130
- const sortDirection = ( ! this . props . sortDirection && ! this . state . sortDirection && this . props . sortable ) ? this . props . firstSortDirection : ( this . props . sortDirection || this . state . sortDirection ) ;
136
+ // const sortDirection = (!this.props.sortDirection && !this.state.sortDirection && this.props.sortable) ? this.props.firstSortDirection : (this.props.sortDirection || this.state.sortDirection);
137
+ const sortDirection = this . props . sortDirection || this . state . sortDirection || this . props . firstSortDirection
131
138
const expandedSortDirection =
132
139
sortDirection === 'desc' ? 'descending' : 'ascending' ;
133
140
const ariaSort = isSorted ? expandedSortDirection : 'none' ;
0 commit comments