File tree Expand file tree Collapse file tree 4 files changed +44
-8
lines changed Expand file tree Collapse file tree 4 files changed +44
-8
lines changed Original file line number Diff line number Diff line change 5353 }
5454 }
5555
56+ &-disabled {
57+ cursor : not-allowed ;
58+ & :hover {
59+ border-color : #d9d9d9 ;
60+ a {
61+ color : #d9d9d9 ;
62+ }
63+ }
64+ }
65+
5666 &-active {
5767 background-color : #2db7f5 ;
5868 border-color : #2db7f5 ;
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ const Pager = (props) => {
1313 cls = `${ cls } ${ props . className } ` ;
1414 }
1515
16+ if ( ! props . page ) {
17+ cls = `${ cls } ${ prefixCls } -disabled` ;
18+ }
19+
1620 const handleClick = ( ) => {
1721 props . onClick ( props . page ) ;
1822 } ;
Original file line number Diff line number Diff line change @@ -425,19 +425,32 @@ export default class Pagination extends React.Component {
425425 }
426426
427427 if ( allPages <= 5 + pageBufferSize * 2 ) {
428+ const pagerProps = {
429+ locale,
430+ rootPrefixCls : prefixCls ,
431+ onClick : this . handleChange ,
432+ onKeyPress : this . runIfEnter ,
433+ showTitle : props . showTitle ,
434+ itemRender : props . itemRender ,
435+ } ;
436+ if ( ! allPages ) {
437+ pagerList . push (
438+ < Pager
439+ { ...pagerProps }
440+ key = "noPager"
441+ page = { allPages }
442+ className = { `${ prefixCls } -disabled` }
443+ />
444+ ) ;
445+ }
428446 for ( let i = 1 ; i <= allPages ; i ++ ) {
429447 const active = this . state . current === i ;
430448 pagerList . push (
431449 < Pager
432- locale = { locale }
433- rootPrefixCls = { prefixCls }
434- onClick = { this . handleChange }
435- onKeyPress = { this . runIfEnter }
450+ { ...pagerProps }
436451 key = { i }
437452 page = { i }
438453 active = { active }
439- showTitle = { props . showTitle }
440- itemRender = { props . itemRender }
441454 />
442455 ) ;
443456 }
@@ -578,8 +591,8 @@ export default class Pagination extends React.Component {
578591 </ li >
579592 ) ;
580593 }
581- const prevDisabled = ! this . hasPrev ( ) ;
582- const nextDisabled = ! this . hasNext ( ) ;
594+ const prevDisabled = ! this . hasPrev ( ) || ! allPages ;
595+ const nextDisabled = ! this . hasNext ( ) || ! allPages ;
583596 return (
584597 < ul
585598 className = { `${ prefixCls } ${ props . className } ` }
Original file line number Diff line number Diff line change @@ -705,6 +705,15 @@ describe('current value on onShowSizeChange when total is 0', () => {
705705 } , 10 ) ;
706706 } , 10 ) ;
707707 } ) ;
708+
709+ it ( 'when total is 0, pager should show and disabled' , ( ) => {
710+ const itemButton = TestUtils . findRenderedDOMComponentWithClass (
711+ pagination ,
712+ 'rc-pagination-item'
713+ ) ;
714+ expect ( TestUtils . isDOMComponent ( itemButton ) ) . to . be ( true ) ;
715+ expect ( itemButton . className ) . to . contain ( 'rc-pagination-item-disabled' ) ;
716+ } ) ;
708717} ) ;
709718
710719describe ( 'data and aria props' , ( ) => {
You can’t perform that action at this time.
0 commit comments