From 065e93c0be611867c37daa3a5a7b9642289db685 Mon Sep 17 00:00:00 2001 From: Albert Kaaman Date: Tue, 18 Feb 2020 14:38:08 +0100 Subject: [PATCH] fix(VDataTable): group-by should use correct slot (#10592) closes #10289 Co-authored-by: Andrew Henry --- .../src/components/VDataTable/VDataTable.ts | 2 +- .../VDataTable/__tests__/VDataTable.spec.ts | 19 ++ .../__snapshots__/VDataTable.spec.ts.snap | 243 ++++++++++++++++++ 3 files changed, 263 insertions(+), 1 deletion(-) diff --git a/packages/vuetify/src/components/VDataTable/VDataTable.ts b/packages/vuetify/src/components/VDataTable/VDataTable.ts index d79a1da7037..b424efe3ffb 100644 --- a/packages/vuetify/src/components/VDataTable/VDataTable.ts +++ b/packages/vuetify/src/components/VDataTable/VDataTable.ts @@ -314,7 +314,7 @@ export default VDataIterator.extend({ genDefaultGroupedRow (group: string, items: any[], props: DataScopeProps) { const isOpen = !!this.openCache[group] const children: VNodeChildren = [ - this.$createElement('template', { slot: 'row.content' }, this.genDefaultRows(items, props)), + this.$createElement('template', { slot: 'row.content' }, this.genRows(items, props)), ] const toggleFn = () => this.$set(this.openCache, group, !this.openCache[group]) const removeFn = () => props.updateOptions({ groupBy: [], groupDesc: [] }) diff --git a/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts b/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts index add14887996..1d60f6b2af7 100644 --- a/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts +++ b/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts @@ -672,4 +672,23 @@ describe('VDataTable.ts', () => { expect(input).toHaveBeenNthCalledWith(2, []) }) + + // https://github.com/vuetifyjs/vuetify/issues/10289 + it('should render item slot when using group-by function', async () => { + const wrapper = mountFunction({ + propsData: { + headers: testHeaders, + itemKey: 'name', + items: testItems.slice(0, 2), + groupBy: 'name', + }, + scopedSlots: { + item () { + return this.$createElement('div', ['scoped']) + }, + }, + }) + + expect(wrapper.html()).toMatchSnapshot() + }) }) diff --git a/packages/vuetify/src/components/VDataTable/__tests__/__snapshots__/VDataTable.spec.ts.snap b/packages/vuetify/src/components/VDataTable/__tests__/__snapshots__/VDataTable.spec.ts.snap index 8735eb501e9..eee9fce6d2c 100644 --- a/packages/vuetify/src/components/VDataTable/__tests__/__snapshots__/VDataTable.spec.ts.snap +++ b/packages/vuetify/src/components/VDataTable/__tests__/__snapshots__/VDataTable.spec.ts.snap @@ -3472,6 +3472,249 @@ exports[`VDataTable.ts should render footer.page-text slot content 1`] = ` `; +exports[`VDataTable.ts should render item slot when using group-by function 1`] = ` +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ scoped +
+ + + +
+ scoped +
+ +
+ + Calories + + + + + Fat (g) + + + + + Carbs (g) + + + + + Protein (g) + + + + + Iron (%) + + +
+ + name: Frozen Yogurt + +
+ + name: Ice cream sandwich + +
+
+ +
+`; + exports[`VDataTable.ts should render loading state 1`] = `