@@ -94,6 +94,28 @@ class NumberFilter extends Component {
9494 onFilter ( column , FILTER_TYPE . NUMBER ) ( { number : value , comparator } ) ;
9595 }
9696
97+ getDefaultComparator ( ) {
98+ const { defaultValue, filterState } = this . props ;
99+ if ( filterState && filterState . filterVal ) {
100+ return filterState . filterVal . comparator ;
101+ }
102+ if ( defaultValue && defaultValue . comparator ) {
103+ return defaultValue . comparator ;
104+ }
105+ return '' ;
106+ }
107+
108+ getDefaultValue ( ) {
109+ const { defaultValue, filterState } = this . props ;
110+ if ( filterState && filterState . filterVal ) {
111+ return filterState . filterVal . number ;
112+ }
113+ if ( defaultValue && defaultValue . number ) {
114+ return defaultValue . number ;
115+ }
116+ return '' ;
117+ }
118+
97119 getComparatorOptions ( ) {
98120 const optionTags = [ ] ;
99121 const { withoutEmptyComparatorOption } = this . props ;
@@ -148,7 +170,6 @@ class NumberFilter extends Component {
148170 render ( ) {
149171 const { isSelected } = this . state ;
150172 const {
151- defaultValue,
152173 column,
153174 options,
154175 style,
@@ -184,7 +205,7 @@ class NumberFilter extends Component {
184205 id = { `number-filter-comparator-${ column . text } ` }
185206 className = { `number-filter-comparator form-control ${ comparatorClassName } ` }
186207 onChange = { this . onChangeComparator }
187- defaultValue = { defaultValue ? defaultValue . comparator : '' }
208+ defaultValue = { this . getDefaultComparator ( ) }
188209 >
189210 { this . getComparatorOptions ( ) }
190211 </ select >
@@ -202,7 +223,7 @@ class NumberFilter extends Component {
202223 style = { numberStyle }
203224 className = { selectClass }
204225 onChange = { this . onChangeNumberSet }
205- defaultValue = { defaultValue ? defaultValue . number : '' }
226+ defaultValue = { this . getDefaultValue ( ) }
206227 >
207228 { this . getNumberOptions ( ) }
208229 </ select >
@@ -217,7 +238,7 @@ class NumberFilter extends Component {
217238 className = { `number-filter-input form-control ${ numberClassName } ` }
218239 placeholder = { placeholder || `Enter ${ column . text } ...` }
219240 onChange = { this . onChangeNumber }
220- defaultValue = { defaultValue ? defaultValue . number : '' }
241+ defaultValue = { this . getDefaultValue ( ) }
221242 />
222243 </ label >
223244 }
@@ -229,6 +250,7 @@ class NumberFilter extends Component {
229250NumberFilter . propTypes = {
230251 onFilter : PropTypes . func . isRequired ,
231252 column : PropTypes . object . isRequired ,
253+ filterState : PropTypes . object ,
232254 options : PropTypes . arrayOf ( PropTypes . number ) ,
233255 defaultValue : PropTypes . shape ( {
234256 number : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
@@ -273,6 +295,7 @@ NumberFilter.defaultProps = {
273295 number : undefined ,
274296 comparator : ''
275297 } ,
298+ filterState : { } ,
276299 withoutEmptyComparatorOption : false ,
277300 withoutEmptyNumberOption : false ,
278301 comparators : legalComparators ,
0 commit comments