Skip to content
Permalink
Browse files
fix(b-pagination): properly calculate number of links with `hide-elli…
…psis` option (closes #5514) (#5678)

* fix(b-pagination): properly calculate number of links with `hide-ellipsis` option

* Update pagination.spec.js
  • Loading branch information
jacobmllr95 committed Aug 22, 2020
1 parent 31c06b5 commit 98e17ca85588b858f5d74e217c48fa82f11f487f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
@@ -374,6 +374,25 @@ describe('pagination', () => {
wrapper.destroy()
})

it('has correct number of links when `hide-ellipsis` is enabled', async () => {
const wrapper = mount(BPagination, {
propsData: {
hideEllipsis: true,
totalRows: 100,
perPage: 10,
value: 1
}
})
expect(wrapper.element.tagName).toBe('UL')
expect(wrapper.findAll('li').length).toBe(9)

await wrapper.setProps({ value: 5 })
await waitNT(wrapper.vm)
expect(wrapper.findAll('li').length).toBe(9)

wrapper.destroy()
})

it('has attribute aria-controls on page links when prop aria-controls is set', async () => {
const wrapper = mount(BPagination, {
propsData: {
@@ -223,12 +223,14 @@ export default {
},
paginationParams() {
// Determine if we should show the the ellipsis
const limit = this.localLimit
const numberOfPages = this.localNumberOfPages
const currentPage = this.computedCurrentPage
const hideEllipsis = this.hideEllipsis
const firstNumber = this.firstNumber
const lastNumber = this.lastNumber
const {
localLimit: limit,
localNumberOfPages: numberOfPages,
computedCurrentPage: currentPage,
hideEllipsis,
firstNumber,
lastNumber
} = this
let showFirstDots = false
let showLastDots = false
let numberOfLinks = limit
@@ -252,7 +254,7 @@ export default {
} else {
// We are somewhere in the middle of the page list
if (limit > ELLIPSIS_THRESHOLD) {
numberOfLinks = limit - 2
numberOfLinks = limit - (hideEllipsis ? 0 : 2)
showFirstDots = !!(!hideEllipsis || firstNumber)
showLastDots = !!(!hideEllipsis || lastNumber)
}

0 comments on commit 98e17ca

Please sign in to comment.