🌐 AI搜索 & 代理 主页
Skip to content
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
19 changes: 19 additions & 0 deletions src/components/pagination/pagination.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
16 changes: 9 additions & 7 deletions src/mixins/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down