Skip to content

feat(VDataTable): add new lastFixed property (#21153)#21168

Merged
jcjp merged 5 commits intodevfrom
fix(VDataTable)/last-column-fixed
May 26, 2025
Merged

feat(VDataTable): add new lastFixed property (#21153)#21168
jcjp merged 5 commits intodevfrom
fix(VDataTable)/last-column-fixed

Conversation

@jcjp
Copy link
Contributor

@jcjp jcjp commented Mar 27, 2025

Description

Utilize props lastFixed and make column header fixed on the right.

<template>
  <v-app>
    <v-container>
      <v-data-table
        :headers="header"
        :items="items"
        fixed-header
        style="max-width: 300px"
        last-fixed
      >
        <template #item.key5>
          <v-btn>action btn</v-btn>
        </template>
      </v-data-table>
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref, computed } from 'vue'

  const items = ref([
    { key1: 1, key2: 2, key3: 3, key4: 4, key5: 5 },
    { key1: 1, key2: 2, key3: 3, key4: 4, key5: 5 },
    { key1: 1, key2: 2, key3: 3, key4: 4, key5: 5 },
    { key1: 1, key2: 2, key3: 3, key4: 4, key5: 5 },
    { key1: 1, key2: 2, key3: 3, key4: 4, key5: 5 },
    { key1: 1, key2: 2, key3: 3, key4: 4, key5: 5 },
    { key1: 1, key2: 2, key3: 3, key4: 4, key5: 5 },
  ])

  const header = computed(() => {
    return [
      {
        title: 'col1',
        key: 'key1',
        sortable: false,
      },
      {
        title: 'col2',
        key: 'key2',
        sortable: false,
        minWidth: '100px',
      },
      {
        title: 'col3',
        key: 'key3',
        sortable: false,
        minWidth: '150px',
      },
      {
        title: 'col4',
        key: 'key4',
        sortable: false,
        minWidth: '100px',
      },
      {
        title: 'col5',
        key: 'key5',
        sortable: false,
        minWidth: '100px',
        fixed: true,
      },
    ]
  })
</script>

@jcjp jcjp requested review from KaelWD, Spatlani and johnleider March 27, 2025 11:40
@jcjp jcjp self-assigned this Mar 27, 2025
@jcjp jcjp added T: bug Functionality that does not work as intended/expected C: VDataTable labels Mar 27, 2025
@johnleider johnleider added this to the v3.7.x milestone Mar 27, 2025
@johnleider johnleider force-pushed the fix(VDataTable)/last-column-fixed branch from 5bb1246 to 65efb4c Compare March 27, 2025 14:17
@johnleider johnleider changed the base branch from master to dev March 27, 2025 14:17
@johnleider johnleider changed the title fix(VDataTable): utilize unused lastFixed property feat(VDataTable): add new lastFixed property Mar 27, 2025
@johnleider
Copy link
Member

Rebased to dev since this is a true feature.

@johnleider johnleider force-pushed the fix(VDataTable)/last-column-fixed branch from 65efb4c to 4fa0f59 Compare March 27, 2025 14:21
@johnleider johnleider modified the milestones: v3.7.x, v3.9.0 (Zealot) Mar 27, 2025
@KaelWD
Copy link
Member

KaelWD commented Mar 28, 2025

It isn't unused, it adds a border to the last fixed column:

.v-data-table-column--last-fixed
border-right: 1px solid rgba(var(--v-border-color), var(--v-border-opacity))

@jcjp jcjp requested a review from Arslan038 April 25, 2025 13:56
@jcjp jcjp force-pushed the fix(VDataTable)/last-column-fixed branch from 4fa0f59 to ea2bf1c Compare April 25, 2025 13:57
@jcjp jcjp force-pushed the fix(VDataTable)/last-column-fixed branch from ea2bf1c to 11c8580 Compare May 3, 2025 12:32
@jcjp jcjp requested review from Copilot and removed request for Arslan038 May 3, 2025 12:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new boolean property, lastFixed, to enable right-fixed column header behavior in VDataTable.

  • Adds the lastFixed prop to VDataTableHeaders props.
  • Updates the fixed styles logic to account for lastFixed columns by setting proper left/right styles.
Comments suppressed due to low confidence (2)

packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx:98

  • [nitpick] The updated condition treats a column with either 'fixed' or 'lastFixed' identically. Verify if a column might inadvertently have both properties set and if their combined effect should be differentiated.
if (!(props.sticky || props.fixedHeader) && !(column.fixed || column.lastFixed)) return undefined

packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx:103

  • Using the same 'fixedOffset' for right-fixed columns may limit flexibility if differing offsets are needed for left versus right positioning. Consider introducing a separate offset for right-fixed columns if applicable.
right: column.lastFixed ? convertToUnit(column.fixedOffset ?? 0) : undefined,

@eesayas
Copy link
Contributor

eesayas commented May 5, 2025

Is it possible to not change the interface? Like it's still setting fixed: true in the last header not a new prop.

Copy link
Member

@johnleider johnleider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs language in VDataTableHeaders.json, and also newIn.json

@jcjp
Copy link
Contributor Author

jcjp commented May 18, 2025

Is it possible to not change the interface? Like it's still setting fixed: true in the last header not a new prop.

I played around with it last time Isias but I could not get it work with the fixed props.

@jcjp jcjp force-pushed the fix(VDataTable)/last-column-fixed branch from 446a831 to 5d5d60a Compare May 18, 2025 06:04
@jcjp jcjp requested a review from johnleider May 18, 2025 06:04
@jcjp jcjp dismissed johnleider’s stale review May 18, 2025 06:05

Added entries on the said files John thanks!

jcjp and others added 3 commits May 18, 2025 14:09
this is to ensure that the header will still be sticky for last fixed
chore(VDataTableHeaders): add entry to new-in.json
@jcjp jcjp force-pushed the fix(VDataTable)/last-column-fixed branch from 5d5d60a to 3254530 Compare May 18, 2025 06:09
@jcjp jcjp changed the title feat(VDataTable): add new lastFixed property feat(VDataTable): add new lastFixed property (#21153) May 18, 2025
@jcjp jcjp merged commit 5e1d653 into dev May 26, 2025
18 checks passed
@jcjp jcjp deleted the fix(VDataTable)/last-column-fixed branch May 26, 2025 15:55
J-Sek added a commit to J-Sek/vuetify that referenced this pull request Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VDataTable T: bug Functionality that does not work as intended/expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request][VDataTable] Make the last v-table-column fixed

4 participants

Comments