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): avoid changing page if oldOptions is not defined #19542

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

webdevnerdstuff
Copy link
Contributor

fixes #17966

Description

Fixes initial checking of old search value to include a check for undefined. Without it the condition was always true.

Markup:

<template>
  <v-text-field
    v-model="search"
    label="Search"
  />
  <v-data-table
    :headers="headers"
    :items="desserts"
    :items-per-page="5"
    :page="2"
    :search="search"
  />
</template>

<script setup lang="ts">
  import { ref } from 'vue'

  const search = ref('')

  const headers = ref([
    {
      title: 'Dessert (100g serving)',
      align: 'start',
      sortable: false,
      key: 'name',
    },
    { title: 'Calories', key: 'calories' },
    { title: 'Fat (g)', key: 'fat' },
    { title: '', key: 'data-table-expand' },
  ] as const)
  const desserts = ref([
    {
      name: 'Frozen Yogurt',
      calories: 159,
      fat: 6,
    },
    {
      name: 'KitKat',
      calories: 518,
      fat: 26,
    },
    {
      name: 'Ice cream sandwich with some really long name',
      calories: 237,
      fat: 9,
    },
    {
      name: 'Eclair',
      calories: 262,
      fat: 16,
    },
    {
      name: 'Cupcake',
      calories: 305,
      fat: 3.7,
    },
    {
      name: 'Gingerbread',
      calories: 356,
      fat: 16,
    },
    {
      name: 'Jelly bean',
      calories: 375,
      fat: 0,
    },
    {
      name: 'Honeycomb',
      calories: 408,
      fat: 3.2,
    },
    {
      name: 'Donut',
      calories: 452,
      fat: 25,
    },
    {
      name: 'KitKat',
      calories: 518,
      fat: 26,
    },
  ])
</script>

@webdevnerdstuff webdevnerdstuff marked this pull request as ready for review April 4, 2024 18:51
@webdevnerdstuff
Copy link
Contributor Author

@MajesticPotatoe or @KaelWD does the Cypress test need to be updated for this change? Cypress tests are above my head.

Fail point:
line: 113
vuetify/packages/vuetify/src/components/VDataTable/tests/VDataTable.spec.cy.tsx

cy.emitted(VDataTable, 'update:page')
      .should('deep.equal', [[2], [1]])

@johnleider johnleider added this to the v3.5.x milestone Apr 9, 2024
@johnleider johnleider added T: bug Functionality that does not work as intended/expected C: VDataTableServer labels Apr 9, 2024
@johnleider johnleider changed the title fix(VDataTable): check for old search value type of undefined fix(VDataTable): avoid changing page if oldOptions is not defined Apr 9, 2024
@johnleider johnleider merged commit 37a573d into vuetifyjs:master Apr 9, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VDataTableServer T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.3.11] VDataTable - Unable to set initial page
2 participants