File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,12 @@ class Pagination extends React.Component {
172172
173173 isValid = ( page ) => {
174174 const { total } = this . props ;
175- return isInteger ( page ) && page !== this . state . current && isInteger ( total ) && total > 0 ;
175+ return (
176+ isInteger ( page ) &&
177+ page !== this . state . current &&
178+ isInteger ( total ) &&
179+ total > 0
180+ ) ;
176181 } ;
177182
178183 shouldDisplayQuickJumper = ( ) => {
@@ -206,6 +211,11 @@ class Pagination extends React.Component {
206211 }
207212 } ;
208213
214+ handleBlur = ( e ) => {
215+ const value = this . getValidValue ( e ) ;
216+ this . handleChange ( value ) ;
217+ } ;
218+
209219 changePageSize = ( size ) => {
210220 let { current } = this . state ;
211221 const newCurrent = calculatePage ( size , this . state , this . props ) ;
@@ -476,6 +486,7 @@ class Pagination extends React.Component {
476486 onKeyDown = { this . handleKeyDown }
477487 onKeyUp = { this . handleKeyUp }
478488 onChange = { this . handleKeyUp }
489+ onBlur = { this . handleBlur }
479490 size = "3"
480491 />
481492 < span className = { `${ prefixCls } -slash` } > /</ span >
Original file line number Diff line number Diff line change @@ -22,6 +22,18 @@ describe('simple Pagination', () => {
2222 wrapper . unmount ( ) ;
2323 } ) ;
2424
25+ it ( 'input change value will emit onChange when input blur' , ( ) => {
26+ const onChange = jest . fn ( ) ;
27+ const component = mount (
28+ < Pagination simple total = { 25 } onChange = { onChange } /> ,
29+ ) ;
30+ const greaterCurrent = component . find ( '.rc-pagination-simple' ) ;
31+ const input = greaterCurrent . find ( 'input' ) ;
32+ input . simulate ( 'change' , { target : { value : '2' } } ) ;
33+ input . simulate ( 'blur' ) ;
34+ expect ( onChange ) . toBeCalled ( ) ;
35+ } ) ;
36+
2537 it ( 'default current page is 1' , ( ) => {
2638 expect ( wrapper . state ( ) . current ) . toBe ( 1 ) ;
2739 } ) ;
You can’t perform that action at this time.
0 commit comments