Skip to content

Commit 8b958f3

Browse files
author
Sasha Kondrashov
committed
pagination
1 parent ef8684c commit 8b958f3

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/addons/Pagination/Pagination.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ export interface StrictPaginationProps {
4545
* Called on change of an active page.
4646
*
4747
* @param {SyntheticEvent} event - React's original SyntheticEvent.
48-
* @param {object} data - All props.
48+
* @param {object} props - All props.
49+
* @param {number} activePage - Index of the newly active page.
4950
*/
50-
onPageChange?: (event: React.MouseEvent<HTMLAnchorElement>, data: PaginationProps) => void
51+
onPageChange?: (
52+
event: React.MouseEvent<HTMLAnchorElement>,
53+
props: PaginationProps,
54+
activePage: number,
55+
) => void
5156

5257
/** Number of always visible pages before and after the current one. */
5358
siblingRange?: number | string

src/addons/Pagination/Pagination.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const Pagination = React.forwardRef(function (props, ref) {
5555
}
5656

5757
setActivePage(nextActivePage)
58-
_.invoke(props, 'onPageChange', e, { ...props, activePage: nextActivePage })
58+
_.invoke(props, 'onPageChange', e, props, nextActivePage)
5959
}
6060

6161
const handleItemOverrides = (active, type, value) => (predefinedProps) => ({

test/specs/addons/Pagination/Pagination-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Pagination', () => {
2424
})
2525

2626
describe('onPageChange', () => {
27-
it('is called with (e, data) when clicked on a pagination item', () => {
27+
it('is called when clicked a pagination item is clicked', () => {
2828
const onPageChange = sandbox.spy()
2929
const onPageItemClick = sandbox.spy()
3030

@@ -40,7 +40,7 @@ describe('Pagination', () => {
4040
wrapper.find('PaginationItem').at(4).simulate('click')
4141

4242
onPageChange.should.have.been.calledOnce()
43-
onPageChange.should.have.been.calledWithMatch({ type: 'click' }, { activePage: 3 })
43+
onPageChange.should.have.been.calledWithMatch({ type: 'click' }, {}, 3)
4444
onPageItemClick.should.have.been.calledOnce()
4545
onPageItemClick.should.have.been.calledWithMatch({ type: 'click' }, { value: 3 })
4646
})

0 commit comments

Comments
 (0)