Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Pagination): update handling of onClick for ellipsisItem #3493

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/addons/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class Pagination extends Component {
key: `${type}-${value}`,
onClick: (e, itemProps) => {
_.invoke(predefinedProps, 'onClick', e, itemProps)
this.handleItemClick(e, itemProps)
if (itemProps.type !== 'ellipsisItem') this.handleItemClick(e, itemProps)
},
})

Expand Down
4 changes: 1 addition & 3 deletions src/addons/Pagination/PaginationItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class PaginationItem extends Component {
}

handleClick = (e) => {
const { type } = this.props

if (type !== 'ellipsisItem') _.invoke(this.props, 'onClick', e, this.props)
_.invoke(this.props, 'onClick', e, this.props)
}

handleKeyDown = (e) => {
Expand Down
19 changes: 19 additions & 0 deletions test/specs/addons/Pagination/Pagination-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,24 @@ describe('Pagination', () => {
.simulate('click')
onPageChange.should.have.not.been.called()
})

it('will be omitted when item "type" is "ellipsisItem"', () => {
const onPageChange = sandbox.spy()
const wrapper = mount(
<Pagination
activePage={5}
firstItem={null}
onPageChange={onPageChange}
prevItem={null}
totalPages={10}
/>,
)

wrapper
.find('PaginationItem')
.at(1)
.simulate('click')
onPageChange.should.have.not.been.called()
})
})
})
9 changes: 0 additions & 9 deletions test/specs/addons/Pagination/PaginationItem-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ describe('PaginationItem', () => {
onClick.should.have.been.calledOnce()
onClick.should.have.been.calledWithMatch(event, { onClick })
})

it('is omitted when "type" is "ellipsisItem"', () => {
const event = { target: null }
const onClick = sandbox.spy()

shallow(<PaginationItem onClick={onClick} type='ellipsisItem' />).simulate('click', event)

onClick.should.have.been.not.called()
})
})

describe('onKeyDown', () => {
Expand Down