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:(VDataTable): Slots for tbody and thead not overriding default tags #19413

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

codetakki
Copy link

@codetakki codetakki commented Mar 15, 2024

Fixes #18854 where tbody slot does not replace the default tbody

Description

The tbody slot was placed after the tbody tag, resulting in the slot just being appended to the body.
Trying to add any custom tbody inside the body slot results in broken styling, making it harder to customize tables.
It seems to have worked as expected in v2, if understanding this Stackoverflow comment correctly

Markup

<template>
  <div>
    <v-data-table
      :headers="headers"
      :items="items"
      :items-per-page="-1"
      item-key="name"
    >
      <template #thead>
        <thead>
          <tr>
            <th>
              Name
            </th>
            <th>
              Sport
            </th>
            <th>
              ID
            </th>
          </tr>
        </thead>
      </template>
      <template #tbody>
        <tbody>
          <tr
            v-for="item in items"
            :key="item.name"
          >
            <td v-for="header in headers" :key="header">{{ item[header.value] }}</td>
          </tr>
        </tbody>
      </template>
    </v-data-table>
  </div>

</template>
<script>

  export default {
    data () {
      return {
        items: [
          { id: 1, name: 'Abby', sport: 'basket' },
          { id: 2, name: 'Brooke', sport: 'foot' },
          { id: 3, name: 'Courtenay', sport: 'volley' },
          { id: 4, name: 'David', sport: 'rugby' },
          { id: 5, name: 'Emma', sport: 'tennis' },
          { id: 6, name: 'Finn', sport: 'soccer' },
          { id: 7, name: 'Grace', sport: 'swimming' },
          { id: 8, name: 'Henry', sport: 'baseball' },
          { id: 9, name: 'Isaac', sport: 'hockey' },
          { id: 10, name: 'Jasmine', sport: 'badminton' },
          { id: 11, name: 'Kai', sport: 'cricket' },
          { id: 12, name: 'Liam', sport: 'golf' },
          { id: 13, name: 'Mia', sport: 'surfing' },
          { id: 14, name: 'Noah', sport: 'skiing' },
          { id: 15, name: 'Olivia', sport: 'snowboarding' },
          { id: 16, name: 'Peyton', sport: 'cycling' },
          { id: 17, name: 'Quinn', sport: 'running' },
          { id: 18, name: 'Ryan', sport: 'wrestling' },
          { id: 19, name: 'Sophia', sport: 'boxing' },
          { id: 20, name: 'Tyler', sport: 'surfing' },
        ],
        headers: [
          {
            title: 'Name',
            value: 'name',
          },
          {
            title: 'sport',
            value: 'sport',
          },
          {
            title: 'id',
            value: 'id',
          },
        ],
      }
    },
  }
</script>
@MajesticPotatoe MajesticPotatoe added T: bug Functionality that does not work as intended/expected C: VDataTable VDatatable labels Mar 19, 2024
@codetakki

This comment was marked as off-topic.

@KaelWD
Copy link
Member

KaelWD commented Mar 20, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VDataTable VDatatable S: stale This issue is untriaged and hasn't seen any activity in at least six months. T: bug Functionality that does not work as intended/expected
4 participants