vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

[Bug Report][3.8.8] VDataTableServer fires update:options twice when setting page to 1 on search

Open tlloydthwaites opened this issue 7 months ago • 1 comments

Environment

Vuetify Version: 3.8.8 Vue Version: 3.5.16 Browsers: Chrome 137.0.0.0 OS: Mac OS 10.15.7

Steps to reproduce

  • Create a VDataTableServer with bound search
  • Go to page 2
  • Enter a search 'x'
  • update:options will be fired with { page: 2, search: 'x' }
  • update:options will be fired with { page: 1, search: 'x' }

Expected Behavior

If options watcher is going to change the data, it should not fire the watcher twice.

Actual Behavior

It fires the watcher twice, which can lead to double load.

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

in VDataTable/composables/options.ts:38

    // Reset page when searching
    if (oldOptions && oldOptions.search !== value.search) {
      page.value = 1
      return; // <----- the above will fire the watcher again, so don't emit
    }

tlloydthwaites avatar Jun 11 '25 04:06 tlloydthwaites

At the moment I am storing table options in a tableOptions ref and using in a computed nuxt query, so changing this will refire a request.

The workaround is a to bind a function to update:options that skips updating tableOptions.value if search != "" && page != 1, knowing that another update is coming. But that's a bit ugly.

tlloydthwaites avatar Jun 11 '25 04:06 tlloydthwaites

Isn't a debounce a solution that would appear in this scenario anyway?

J-Sek avatar Aug 27 '25 21:08 J-Sek