@@ -5,7 +5,7 @@ import Icon from '../icon';
5
5
import Button from '../button' ;
6
6
import Input from '../input' ;
7
7
import ConfigProvider from '../config-provider' ;
8
- import { func , obj } from '../util' ;
8
+ import { func , obj } from '../util' ;
9
9
10
10
/** NumberPicker */
11
11
class NumberPicker extends React . Component {
@@ -259,7 +259,7 @@ class NumberPicker extends React.Component {
259
259
} ) ;
260
260
}
261
261
262
- this . props . onChange ( isNaN ( v ) || v === '' ? undefined : v , { ...e , triggerType} ) ;
262
+ this . props . onChange ( isNaN ( v ) || v === '' ? undefined : v , { ...e , triggerType } ) ;
263
263
}
264
264
265
265
setInputValue ( v , e ) {
@@ -299,7 +299,7 @@ class NumberPicker extends React.Component {
299
299
}
300
300
301
301
upStep ( val ) {
302
- const { step, min} = this . props ;
302
+ const { step, min } = this . props ;
303
303
const precisionFactor = this . getPrecisionFactor ( ) ;
304
304
let result ;
305
305
if ( typeof val === 'number' ) {
@@ -313,7 +313,7 @@ class NumberPicker extends React.Component {
313
313
}
314
314
315
315
downStep ( val ) {
316
- const { step, min} = this . props ;
316
+ const { step, min } = this . props ;
317
317
const precisionFactor = this . getPrecisionFactor ( ) ;
318
318
let result ;
319
319
if ( typeof val === 'number' ) {
@@ -344,17 +344,23 @@ class NumberPicker extends React.Component {
344
344
if ( e ) {
345
345
e . preventDefault ( ) ;
346
346
}
347
- const { disabled, min, max} = this . props ;
347
+
348
+ const { disabled, min, max } = this . props ;
348
349
if ( disabled ) {
349
350
return ;
350
351
}
352
+
351
353
const value = this . state . value ;
352
354
if ( isNaN ( value ) ) {
353
355
return ;
354
356
}
355
- const val = this [ `${ type } Step` ] ( value ) ;
356
- if ( val > max || val < min ) {
357
- return ;
357
+
358
+ let val = this [ `${ type } Step` ] ( value ) ;
359
+ if ( val > max ) {
360
+ val = max ;
361
+ }
362
+ if ( val < min ) {
363
+ val = min ;
358
364
}
359
365
this . setValue ( val , e , type ) ;
360
366
}
@@ -382,7 +388,7 @@ class NumberPicker extends React.Component {
382
388
}
383
389
384
390
render ( ) {
385
- const { type, prefix, disabled, style, className, size, max, min, autoFocus, editable, state} = this . props ;
391
+ const { type, prefix, disabled, style, className, size, max, min, autoFocus, editable, state } = this . props ;
386
392
387
393
const prefixCls = `${ prefix } number-picker` ;
388
394
@@ -410,22 +416,22 @@ class NumberPicker extends React.Component {
410
416
if ( type === 'normal' ) {
411
417
innerAfter = ( [
412
418
< Button disabled = { disabled || upDisabled } onClick = { this . up . bind ( this ) } key = "0" >
413
- < Icon size = "xxs" type = "arrow-up" />
419
+ < Icon size = "xxs" type = "arrow-up" />
414
420
</ Button > ,
415
421
< Button disabled = { disabled || downDisabled } onClick = { this . down . bind ( this ) } key = "1" >
416
- < Icon size = "xxs" type = "arrow-down" />
422
+ < Icon size = "xxs" type = "arrow-down" />
417
423
</ Button >
418
424
] ) ;
419
425
innerAfterClassName = `${ prefixCls } -handler` ;
420
426
} else {
421
427
addonBefore = (
422
428
< Button size = { size } disabled = { disabled || downDisabled } onClick = { this . down . bind ( this ) } >
423
- < Icon type = "minus" size = "xs" />
429
+ < Icon type = "minus" size = "xs" />
424
430
</ Button >
425
431
) ;
426
432
addonAfter = (
427
433
< Button size = { size } disabled = { disabled || upDisabled } onClick = { this . up . bind ( this ) } >
428
- < Icon type = "add" size = "xs" />
434
+ < Icon type = "add" size = "xs" />
429
435
</ Button >
430
436
) ;
431
437
}
0 commit comments