File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ const PaginationButton = React.createClass({
30
30
} ,
31
31
32
32
handleClick ( event ) {
33
+ if ( this . props . disabled ) {
34
+ return ;
35
+ }
36
+
33
37
if ( this . props . onSelect ) {
34
38
let selectedEvent = createSelectedEvent ( this . props . eventKey ) ;
35
39
this . props . onSelect ( event , selectedEvent ) ;
Original file line number Diff line number Diff line change @@ -175,4 +175,33 @@ describe('Pagination', function () {
175
175
ReactTestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) [ 2 ]
176
176
) ;
177
177
} ) ;
178
+
179
+ it ( 'should not fire "onSelect" event on disabled buttons' , function ( ) {
180
+ function onSelect ( ) {
181
+ throw Error ( 'this event should not happen' ) ;
182
+ }
183
+
184
+ const instance = ReactTestUtils . renderIntoDocument (
185
+ < Pagination
186
+ onSelect = { onSelect }
187
+ last
188
+ next
189
+ ellipsis
190
+ maxButtons = { 1 }
191
+ activePage = { 1 }
192
+ items = { 0 } />
193
+ ) ;
194
+ const liElements = ReactTestUtils . scryRenderedDOMComponentsWithTag ( instance , 'li' ) ;
195
+
196
+ // buttons are disabled
197
+ assert . include ( React . findDOMNode ( liElements [ 0 ] ) . className , 'disabled' ) ;
198
+ assert . include ( React . findDOMNode ( liElements [ 1 ] ) . className , 'disabled' ) ;
199
+
200
+ const pageButtons = ReactTestUtils . scryRenderedDOMComponentsWithTag ( instance , 'a' ) ;
201
+ const nextButton = pageButtons [ 0 ] ;
202
+ const lastButton = pageButtons [ 1 ] ;
203
+
204
+ ReactTestUtils . Simulate . click ( nextButton ) ;
205
+ ReactTestUtils . Simulate . click ( lastButton ) ;
206
+ } ) ;
178
207
} ) ;
You can’t perform that action at this time.
0 commit comments