Skip to content

Commit

Permalink
fix(VDataTable): emit pagination event when filtering (#10651)
Browse files Browse the repository at this point in the history
closes #10212
  • Loading branch information
nekosaur authored Feb 25, 2020
1 parent 4d04771 commit 7856dba
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vuetify/src/components/VData/VData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export default Vue.extend({
handler (options: DataOptions, old: DataOptions) {
if (deepEqual(options, old)) return
this.$emit('update:options', options)
this.$emit('pagination', this.pagination)
},
deep: true,
immediate: true,
Expand Down Expand Up @@ -257,6 +256,12 @@ export default Vue.extend({
},
immediate: true,
},
pagination: {
handler () {
this.$emit('pagination', this.pagination)
},
immediate: true,
},
},

methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,4 +732,63 @@ describe('VDataTable.ts', () => {

expect(wrapper.html()).toMatchSnapshot()
})

// https://github.com/vuetifyjs/vuetify/issues/10392
it('should emit pagination event when filtering', async () => {
const headers = [
{
text: 'Name',
value: 'name',
},
{
text: 'ID',
value: 'id',
},
]

const items = [
{
name: 'Assistance',
id: 1,
},
{
name: 'Candidat',
id: 2,
},
]

const pagination = jest.fn()

const wrapper = mountFunction({
propsData: {
headers,
items,
itemKey: 'id',
},
listeners: {
pagination,
},
})

expect(pagination).toHaveBeenLastCalledWith({
itemsLength: 2,
itemsPerPage: 10,
page: 1,
pageCount: 1,
pageStart: 0,
pageStop: 2,
})

wrapper.setProps({ search: 'candidat' })
await wrapper.vm.$nextTick()

expect(pagination).toHaveBeenLastCalledWith({
itemsLength: 1,
itemsPerPage: 10,
page: 1,
pageCount: 1,
pageStart: 0,
pageStop: 1,
})
})
})

0 comments on commit 7856dba

Please sign in to comment.