Display tooltips for Autocomplete dropdown options using Vuetify

Just starting out with Vue.js and Vuetify

Issue - Need to display tooltips on each dropdown item in v-autocomplete

Resolution - included the v-tooltip component in the item template

Code:

var app = new Vue({
  el: "#app",
  data: {
    items: [{
        value: 0,
        text: "Matthews Webb"
      },
      {
        value: 1,
        text: "Teresa Ward"
      },
      {
        value: 2,
        text: "Cervantes Swanson"
      },
      {
        value: 3,
        text: "Helga Cooper"
      },
      {
        value: 4,
        text: "Solomon Jensen"
      },
      {
        value: 5,
        text: "Eliza Delgado"
      },
      {
        value: 6,
        text: "Dickson Parks"
      },
      {
        value: 7,
        text: "Etta Glenn"
      },
      {
        value: 8,
        text: "Alma Durham"
      },
      {
        value: 9,
        text: "Rosemary Conner"
      }
    ],
    selected: []
  }
});
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="22545747564b445b62130c5a">[email protected]</a>/dist/vuetify.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b6c0c3d3c2dfd0cff68798ce">[email protected]</a>/dist/vuetify.js"></script>
<div id="app">
  <v-app>
    <v-content>
      <v-container>
        <v-autocomplete :items="items" v-model="selected" clearable multiple>
          <template v-slot:item="data">
            <v-tooltip right>
              <template slot="activator" slot-scope="{ on }">
                <v-list-tile-action>
                  <v-checkbox v-model="selected" :value="data.item.value"></v-checkbox>
                </v-list-tile-action>
                <v-list-tile-content>
                  <v-list-tile-title v-html="data.item.text" v-on="on"></v-list-tile-title>
                </v-list-tile-content>
              </template>
          <span>{{ data.item.text }}</span>
          </v-tooltip>
          </template>
        </v-autocomplete>
      </v-container>
    </v-content>
  </v-app>
</div>

Challenges encountered post implementing the solutions:

  1. The checkboxes are not responsive or selectable when clicked on
  2. Some checkboxes show up as selected after searching for an item

Vue Version - 2.6.12

Vuetify Version - 1.5.24

Is there an alternative method to display tooltips on autocomplete dropdown items without disrupting the functionality, or is there an error in my solution?

Answer №1

Solution:

The overlapping issue between the input box of the selection control and the

v-input--selection-controls__ripple
Div led to binding to the click event instead. I resolved this by implementing a simple CSS Hack, positioning it above using position and setting z-index:-10 for the div. These changes are demonstrated with annotations marked below as /* <--------------- */

<div class="v-input__slot">
    <div class="v-input--selection-controls__input">
        <input aria-checked="false" role="checkbox" type="checkbox" value="1" style="
        position: relative; /* <--------------- */
        ">
        <div class="v-input--selection-controls__ripple" style="
        position: absolute; z-index: -10; /* <--------------- */        
        "></div>
        <i aria-hidden="true" class="v-icon material-icons theme--light">check_box_outline_blank</i>
    </div>
</div>

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

Tips for setting up the Top Menu and Left Side Menu in your system

You're looking to incorporate both the Top Menu and Left Side Menu. The top menu should remain fixed at the top of the page. Implementing the Left Side Menu below the Top Menu has been a challenge. It's currently covering the top menu, which is ...

Is there a way to utilize a variable as a key within an object?

Can this be done? Take a look at a practical example from the real world: var userKey = "userIdKey"; chrome.storage.sync.set({ userKey: "Hello World" }, function () { chrome.storage.sync.get(userKey, function (data) { console.log("In sync:", ...

What are some methods for embedding HTML content onto a specific section of a webpage in a Node.js + Express application, without displaying it as the

Objective My goal is to insert a portion of HTML into a web page. Issue The page is not displaying properly with the desired styling and layout. I have a specific page that must be written in plain HTML rather than Jade, although I will still be usin ...

Is the reference to a variable within an array maintained by JavaScript?

I'm working with react code and using the find() method to select an item from an array. When I retrieve an item from the array, is JavaScript copying the item or returning a reference? EDIT: The items in my array are objects, such as [{id: 12, name ...

Optimal Timing for Loading Initial State from Database Using Vuex

In my Vue/Vuex project, I have a simple setup where I retrieve a list of categories from my database using an HTTP GET request. Before implementing Vuex, I used to fetch this data directly in my main component when it was created. Now with Vuex, I have g ...

Exploring the world with Vue JS and the Google Maps Street View API

My system is currently functioning with JQuery but is not working with Vue JS. I am using the Google Maps API and I am unsure of how to integrate this API with Vue JS. Please assist me with this issue. Apologies for any language barriers :( This method ...

Dynamic manipulation of classes based on user attributes

One thing I've noticed is that certain WordPress themes, like 'Thematic', include user-specific classes in the body element to avoid using CSS browser hacks. For example: wordpress y2010 m02 d26 h05 home singular slug-home page pageid-94 pa ...

Adding an external CSS file to your .scss files with webpack: A step-by-step guide

Currently, I am working on a JavaScript application that I am compiling using Webpack. The application is split into two separate bundles - one for the custom code called App and another for the frameworks called Vendor. The App bundle consists of all the ...

The port has not been defined

My Node server appears to be operational, however the console is displaying an error message stating that the port is undefined. const express = require('express'); const env = require('dotenv') const app = express(); env.config(); ap ...

What is the best way to extract the ID of an element that triggers an OnChange event?

Just a heads up: The solution to my problem ended up being CSS code that was triggered by clicking on a widget. Once I realized it was CSS, along with the widget name and hover action, I was able to handle it successfully. Previous question before the PS ...

What methods can be utilized to retrieve multiple objects based on their names?

It appears that it's not necessary for objects in the scene to have unique names; multiple objects can share the same name... If I need a list of these objects, do I need to create a getObjectsByName method or is there an alternative way to achieve t ...

Center-align the content in Material UI Typography by using the variant attribute for the caption

I'm struggling to center the content of my Typography elements with default and caption variants using the align="center" property. The alignment doesn't seem to be working properly, especially for the variant as caption. Here is a snip ...

State variables in React hooks like useState always return the previous value before

Whenever I choose a value, it seems to always display the previously selected option instead of the current one. What I really want is for the selection to update and store the current value immediately. const [postsPerPage, setPostsPerPage] = useState(1 ...

How can you handle setting an array in JavaScript if a key/value pair does not exist when attempting to get it from a JSON object?

When dealing with a large JSON table stored in localStorage and a user-provided key, I need to access the associated value. However, if the key and/or value does not exist, my intention is to create them. But there's a roadblock... The JSON data prov ...

"Resizing issue with multiple Highcharts not being resolved after selecting a new option from

Is there a way to resize multiple Highcharts on a webpage by clicking a button? When attempting to update the last chart using a dropdown menu and then clicking the resize button, an error message stating Uncaught TypeError: Cannot read property 'refl ...

Guide to retrieving fresh information from an API using a desktop application built on node and electron

Looking for advice on efficiently retrieving new order data from the Shopify API for a private desktop application I'm working on. Should I query the API at regular intervals while the application is active, or is there a way to implement webhooks in ...

Deactivate the button using jQuery if a specific string is found within a line

Looking for assistance with my website building project using jquery-1.10.2. I need to prevent the inclusion of css related strings like <style>, <link> etc. If any of these strings are detected, I want to disable the submit button. Currently, ...

An error handling event for XHTML compliance, similar to the HTML onerror event, is designed to address the issue of

Below is a piece of code that handles hiding the placeholder (imagecontent) for dynamically populated empty images and their captions: <head> <script type="text/javascript"> function hideEmptyImage() { document.getElementById(&q ...

Are AJAX webservices considered extensions of the web or business layer?

Can web services be effectively categorized as extensions of the presentation/web layer or the biz/data layer? It may appear to be a simple question. After all, they are called web services, implying they belong to the web tier. However, as I work on deve ...

Tips on minimizing the size of a data:image/png;base64 file in Javascript and Next.js

My project website is experiencing a significant decrease in performance due to the large number of images I am working with, resulting in warnings from Next.js. In order to optimize database storage and overall performance, I need to reduce the file size ...