Prevent the cursor from moving when the focus changes in Vuetify

I created a code pen that allows the user to trigger the dropdown menu for the second v-autocomplete by entering text in the first v-autocomplete. I achieved this by setting isFocused to true. However, an issue arises where the cursor automatically moves to the next v-autocomplete. Is there a way to prevent this behavior or another method to display the dropdown menu for the second v-autocomplete?

Check out my code pen at: https://codepen.io/aaronk488/pen/MWbKNOq?editors=1010

HTML

<div id="app">
<v-app>
    <v-container >
    <v-row >
        <v-col cols="4" md="4">
        <v-autocomplete
            ref="autocomplete"
            label="Autocomplete"
            :items="components"
            :search-input.sync="search"
            hint="need to open menu on focus, just like click"                     persistent-hint
        ></v-autocomplete>
          </v-col>
          <v-col cols="4" md="4">
            <v-autocomplete
            ref="autocomplete2"
            label="Autocomplete2"
            :items="components2"
            hint="need to open menu on focus, just like click this"                     persistent-hint
        ></v-autocomplete>
        </v-col>
    </v-row>
    </v-container>
</v-app>
</div>

JS

new Vue({
  el: "#app",
  vuetify: new Vuetify(),
  data: {
    search: null,
        components: [
          'Autocompletes', 'Comboboxes', 'Forms', 'Inputs', 'Overflow Buttons', 'Selects', 'Selection Controls', 'Sliders', 'Textareas', 'Text Fields',
        ],
            components2: [
          'Autocompletes2', 'Comboboxes2', 'Forms2', 'Inputs2', 'Overflow Buttons2', 'Selects2', 'Selection Controls2', 'Sliders2', 'Textareas2', 'Text Fields2',
        ],
  },
  watch: {
    search(){
      this.$refs.autocomplete2.isMenuActive = true;
      this.$refs.autocomplete2.isFocused = true;
    }
  },
})

Image https://i.sstatic.net/iwJkj.png

Answer №1

If you want to achieve the desired outcome, consider using both an autocomplete and a select component in your code.

Make sure to assign the provided code snippet to the search(val) method for optimal results.

this.$refs.autocomplete2.$refs.menu.isActive = true;
this.$refs.autocomplete2.blur();

Check out the live demo here

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

Extract the value of an HTML tag and assign it to a variable

Can someone help me out with this, as I am not very familiar with Smarty: When I use ajax to submit this form: <form accept-charset="UTF-8" method="post" onSubmit="return validate()"> <input type="text" name="code" maxlength="15" class=" ...

How is it possible for JavaScript functions to be accessed prior to being defined?

Similar Question: Why can I access a function before it's declared in JavaScript? Unexpectedly, the following code results in an error due to the undefined Foo: window.Foo = Foo; This code snippet also triggers the same error: window.Foo = Foo ...

Retrieve characteristics from removed or replicated entities and allocate them to different entities

Looking for a bit of assistance with an array transformation: [ {Code:13938, Country:699, Name:"Crocs", codeProduct:1} {Code:13952, Country:699, Name:"Polo Club", codeProduct:14} {Code:13952, Country:699, Name:"Polo Club", codeProduct:1} {Code ...

What are some strategies for getting neglected distribution files onto Bower despite being ignored by git?

I am in the process of creating a package for NPM and Bower. To maintain organization, I store my working files (ES6) in the src/ directory of the package and compile the distribution files (ES5, using Babel) in the lib/ directory. For version control, I ...

Data will not bind with Laravel and Vue

I am currently working on a Laravel project and trying to develop a basic editing feature for posts. My approach involves using Vue.js 2 to bind the data, but unfortunately, I am facing issues with displaying it - I'm not quite sure what's causin ...

Angular directive not firing event within compile function

I've attempted many times without success. How can I activate ng-click in a scenario where it is bound in the compile function? function() { return { restrict: 'EA', compile: function(element, attr) { ...

The `indexOf` function cannot be properly executed within a Vue mutation if the action involves a promise

I'm facing a challenge with using indexOf inside a vuex mutation when calling an action that returns a promise. Here is the action code: export const deleteItem = ({commit}, item) => { return new Promise((resolve, reject) => { Vue.h ...

Having trouble with opening and closing popup windows in JavaScript while using Android frames?

To display additional information for the user, I create a new tab using the following code: window.open("/Home/Agreement", "_blank"); Within the Agreement View, there is a button with JavaScript that allows the user to close the Popup and return to the m ...

Utilizing ng-options to pass values rather than entire objects

Currently, I am parsing a .json file and displaying all available options in a select dropdown menu: <div bo-switch-when="dropdown"> <fieldset> <select ng-options="options.text for option in question.body.options" ng-model="question ...

Issue with Vue.js: Child component emitting event but parent component method not triggering

When a child component makes an input change, it emits an event with some data: Vue.component('gum-option', { inheritAttrs: false, props: ['label'], template: ` <label class="gum-option"> ...

What is the best way to show instructions immediately upon receipt of a response?

I'm currently working on developing a website similar to ChatGpt using the OpenAI API for GPT. However, there is a delay in generating responses with GPT taking a few seconds. As a result, my code only displays the instruction once the response from G ...

Obtaining the text content of a <div> element when clicked using Selenium

I am trying to extract the email address from the code snippet below, but I am unsure of how to do it. Any assistance would be greatly appreciated! <div class="taLnk hvrIE6 fl" onclick="ta.trackEventOnPage('Listing', 'Email', 774169 ...

The redirection code is not being executed when calling .pipe() before .subscribe()

My AuthService has the following methods: signUp = (data: SignUp): Observable<AuthResponseData> => { const endpoint = `${env.authBaseUrl}:signUp?key=${env.firebaseKey}`; return this._signInOrSignUp(endpoint, data); }; signIn = (data: SignIn): ...

Can Javascript templates help improve server performance compared to PHP templates?

I'm in the process of developing a website that heavily relies on client-side technologies like Symfony2, Backbone.js, and Underscore. Symfony2 is used for the backend, while Backbone.js powers the frontend. In Symfony2, Twig templates are used and co ...

Conceal a form field depending on the data retrieved from a database in PHP

I need assistance with hiding an input field based on the chosen value from a dropdown. There are two values, stone1 and stone2, that are automatically populated from a database. My goal is to hide the "karat" input field if stone1 is selected, hide the "c ...

What strategies can be utilized to raise the max-height from the bottom to the top?

I am facing the following coding challenge: <div id = "parent"> <div id = "button"></div> </div> There is also a dynamically generated <div id="list"></div> I have successfully implem ...

Utilize the functionName() method within a different function

There is a function this.randomNumber() that produces a random number like 54851247. The task at hand is to access this function within another function. console.log(this.randomNumber()); // Output: 54851247 function anotherFunction() { console.log(t ...

Combining Angular JS 1 and Laravel 5.2 for seamless integration

Currently, I am in the process of setting up Angular JS 1 with Laravel 5.2 by installing the necessary dependencies using npm. After installation, a node_modules folder was created alongside the app directory. My primary concern is whether it is recommend ...

Is the each() method in jQuery essentially a for loop?

Experimenting with adding a serialized class to a group of objects, I attempted the following approach: jQuery('#preload img').each(function(){ jQuery('#thumbs').append('<img class="index' + index + '" src="&apos ...

Alter the background color of a div contingent on the checkbox being checked within

I am in search of a solution to modify the background color of a parent div that contains a checkbox. The condition is that the background color should only change when the 'checked' attribute is present within the tag. HTML <div class="comp ...