The Vuetify asynchronous search feature is only able to send single characters at a time, and it doesn't concatenate the characters

In my Vue component, I have the following code:

<template>
    <v-form ref="form" @submit.prevent="search">
        <v-row class="pa-0">
            <v-col cols="12" md="2" class="d-flex">
                <v-autocomplete
                    :items="projects"
                    item-value="id"
                    :item-text="item =>  `${item.number.number} ${item.name}`"
                    outlined
                    v-model="form.project_id"
                    label="Project number"
                    :search-input.sync="project"
                    dense
                    hide-details="auto"
                    class="align-self-center"
                    clearable
                />
            </v-col>
         </v-row>
       </v-form>
</template>

<script>
export default {
   watch: {
      project( value )
            {
                this.queryProjects( { search: '', number: value } );
            }
   },

   data()
   {
        return {
            project: '',
            projects: [],
            }
        },

     methods: {
            async queryProjects( search )
            {
                console.log(search);
                if(!search)
                {
                    return;
                }

                let response = await fetch(route('projects.search', search));
                this.projects = await response.json();
            },
    }
}
</script>

This Vue component is designed to filter projects based on their project numbers. However, there seems to be an issue with the value passed from the project watcher. Each time a new number is entered in the autocomplete field, it resets back to null instead of concatenating the complete project number. For example, entering "19320" would result in each character being treated individually rather than as a whole number.

When a character is typed, the output in the console shows:

  • 1 for the watcher value
  • {number: "1"} for the queryProject search value
  • null for the watcher value, indicating that each character input causes the input to reset or the component to rerender.

Answer №1

The issue stemmed from a specific line of code

:item-text="item =>  `${item.number.number} ${item.name}`"

Simply changing it to item-text="name" resolved the problem completely.

You can check out a related bug report at: https://github.com/vuetifyjs/vuetify/issues/11370

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Oops! Encounter an issue while trying to deploy VueJS App on Firebase Hosting

I recently developed a Vue application and integrated firebase tools to deploy it on Firebase hosting. Initially, everything worked fine when I ran npm run build and firebase deploy. However, upon making changes and attempting to use commands like npm run ...

Using an AJAX self-invoked function to update Vue data

I have been attempting to utilize a self-invoked function for an ajax call. However, I am facing issues when trying to use the response to populate a data property within Vue. This is the code I have implemented: //Ajax call to service var getData = (fun ...

Is it possible to access the $data variable from a Mixin.js file in Store.js using Vue.js?

My Mixin file has the following structure: export default { data: function() { return { analysisTime: "nothing", phantomPrefix: "One more", } }, methods: { isGeneric: function( ...

A subordinate offspring triggers a signal to the ancestor of its guardian

Is it possible for a child of a sub-child to emit an event directly to its grandparent's parent? In other words, can component-3, which is a child of component-2, emit an event to component-1, the parent of component-2? component1.vue <component- ...

Capturing network issues while utilizing apollo-module with Nuxt

Currently, I am utilizing nuxt in conjunction with apollo-module. My main objective is to be able to intercept any potential network errors, specifically 401/403 errors, in order to display an error modal and log out the user. As per the documentation, it ...

Exploring Vue: A Guide to Utilizing Directives Provided by Libraries

I am attempting to utilize the library found here: https://github.com/rigor789/vue-scrollto However, I am encountering difficulties with utilizing it and the provided instructions are not very clear. The instructions state that I should do the following: ...

In Production environment, v-model triggers a ReferenceError

My Vue View includes the following code: <script setup> import Overwrite from "../components/Overwrite.vue"; </script> <template> <div> ... <textarea v-model="text" cols="99" rows=&qu ...

Unable to access Vue component method beyond its scope

Having an issue with my Vue component that I'm trying to call a method from outside its wrapper element #app. Is there a way to register the component so I can easily call it like Component.function(); var viewController = new Vue({ el: "#app", ...

Ways to maintain an array in Vuex even after mutations take place? (Specifically focusing on persisting data through browser refresh)

I am in the process of developing a basic shopping cart and I need guidance on how to persist an array containing cart data when executing the addProduct mutation below. Is there a way to save this data temporarily to prevent it from being lost due to br ...

Vue 3 Composable console error: Unable to access properties of undefined (specifically 'isError') due to TypeError

I recently developed a Vue 3 / TypeScript Composable for uploading images to Firebase storage. The code snippet below illustrates the structure of the ImageUpload interface: interface ImageUpload { uploadTask?: UploadTask; downloadURL?: string; progr ...

What are the steps to integrate MaterializeCss into Vue.js?

I prefer not to utilize Vue-Material or Vuetify. My choice is Materialize. Here's what I do: npm install materialize-css@next In my main.js file, where I define my new Vue App, I import Materialize like this: import 'materialize-css' Th ...

The issue with Vuex and Typescript is that when using mutation object payloads, they are consistently undefined

Every time I run my code, the object payload I'm passing as a secondary parameter to my Vuex mutation method ends up being undefined. Both my Vuex and component files are coded in TypeScript. When looking at my index.ts file for my Vuex store (where ...

I am looking for information on how to properly handle HTTP errors in Axios when utilizing a blob responseType in VueJs

Using the blob responseType with Axios in my VueJS app allows me to download a document from the server. Everything works fine when the response code is 200, but problems arise when there's an HTTP error. I find it challenging to read the status code ...

The Vue component's TypeScript object prop type does not match the expected value

Having trouble with the type of Object properties in Vue Single File Components using TypeScript (created with Vue CLI 3)? Check out the example below to see the issue. The type of this.product is currently showing as (() => any) | ComputedOptions<a ...

Interact with parent function from child component using data attribute in Vue.js

I have a parent component called Waypoint that contains child elements. I want to be able to call functions on these child elements from the parent component. How can I achieve this? //coding example //template <Waypoint> <div :data-wp-cb ...

Passing Parameters Using Axios in Vue.js

Currently, I am utilizing Axios within VueJS to make ajax requests. However, I have encountered an issue when attempting to send these requests. This snippet shows my JavaScript code: axios.post('http://localhost/app/php/search.php', { quer ...

Vuejs fails to properly transmit data

When I change the image in an image field, the new image data appears correctly before sending it to the back-end. However, after sending the data, the values are empty! Code Commented save_changes() { /* eslint-disable */ if (!this.validateForm) ...

Unable to vertically scroll on a position fixed element

I recently created a unique VueJS component that enables vertical scrolling. Within this component, there are two elements each with a height of 100vh. At the bottom of the component is a fixed position div. Interestingly, when I try to scroll down using m ...

Can dynamic object properties be utilized in Firestore?

Is it possible to save dynamic variables, such as a timestamp, as a property in Firestore? I attempted the code below but encountered an error (error: 'timeStamp' is assigned a value but never used) var timeStamp = new Date() db.collection(&apos ...

Tips for designing a multi-level dropdown navbar

I am currently facing an issue with designing a navbar. I am aiming for Multi-Level Dropdowns, but whenever I click on More Services, it automatically closes the main dropdown menu. I have experimented with various approaches, but none of them seem to be ...