Skip to content

Commit 47bd7f6

Browse files
committedAug 4, 2015
[fixed] disabled pagination buttons should not fire 'onSelect'
1 parent 9403a81 commit 47bd7f6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
 

‎src/PaginationButton.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ const PaginationButton = React.createClass({
3030
},
3131

3232
handleClick(event) {
33+
if (this.props.disabled) {
34+
return;
35+
}
36+
3337
if (this.props.onSelect) {
3438
let selectedEvent = createSelectedEvent(this.props.eventKey);
3539
this.props.onSelect(event, selectedEvent);

‎test/PaginationSpec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,33 @@ describe('Pagination', function () {
175175
ReactTestUtils.scryRenderedDOMComponentsWithTag(instance, 'div')[2]
176176
);
177177
});
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+
});
178207
});

0 commit comments

Comments
 (0)