From b34557ef17793f966ca0ea6eeec9b069f6762ae7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 19 Feb 2017 13:49:22 +0800 Subject: [PATCH] Fix Table pagination.onChange arguments react-component/pagination#58 --- components/table/Table.tsx | 4 ++-- components/table/__tests__/Table.pagination.test.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 58e3b90c9d..92ec6ef533 100755 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -500,7 +500,7 @@ export default class Table extends React.Component, any> { }); } - handlePageChange = (current) => { + handlePageChange = (current, ...otherArguments) => { const props = this.props; let pagination = assign({}, this.state.pagination); if (current) { @@ -508,7 +508,7 @@ export default class Table extends React.Component, any> { } else { pagination.current = pagination.current || 1; } - pagination.onChange(pagination.current); + pagination.onChange(pagination.current, ...otherArguments); const newState = { pagination, diff --git a/components/table/__tests__/Table.pagination.test.js b/components/table/__tests__/Table.pagination.test.js index 1e9518af9b..01be4faf38 100644 --- a/components/table/__tests__/Table.pagination.test.js +++ b/components/table/__tests__/Table.pagination.test.js @@ -56,9 +56,10 @@ describe('Table.pagination', () => { it('fires change event', () => { const handleChange = jest.fn(); + const handlePaginationChange = jest.fn(); const noop = () => {}; const wrapper = mount(createTable({ - pagination: { ...pagination, onChange: noop, onShowSizeChange: noop }, + pagination: { ...pagination, onChange: handlePaginationChange, onShowSizeChange: noop }, onChange: handleChange, })); @@ -67,13 +68,15 @@ describe('Table.pagination', () => { expect(handleChange).toBeCalledWith( { current: 2, - onChange: noop, + onChange: handlePaginationChange, onShowSizeChange: noop, pageSize: 2, }, {}, {} ); + + expect(handlePaginationChange).toBeCalledWith(2, 2); }); // https://github.com/ant-design/ant-design/issues/4532