The positioning problem arising from using a Vuetify select dropdown within a datatable

Vuetify datatable is being used with 20 columns, functioning properly. To view all the columns, horizontal scrolling is available.

Filters are needed for each column in the header, achieved using v-slot:header.

An issue arises when clicking on the select box while having the dropdown open and then horizontally scrolling. The position of the dropdown does not stick with the select box and remains fixed on the screen.

To replicate this issue, visit the following CodePen: https://codepen.io/chansv/pen/OJygmjL

Steps to reproduce:

  • Open the above CodePen.
  • Click on the select box in the header.
  • Keep the dropdown open.
  • Scroll the datatable horizontally using the side arrow.
  • The dropdown does not remain aligned with the select box.

This issue only occurs with horizontal scrolling, not vertical scrolling.

If anyone has experienced the same problem, any suggestions on how to fix it would be greatly appreciated.

Below is the code snippet:

<div id="app">
  <v-app id="inspire">
    <v-data-table
      :headers="headers"
      :items="desserts"
      :items-per-page="5"
      class="elevation-1"
      hide-default-header
    >
      <template v-slot:header="{ props }">
        <th v-for="(head, index) in props.headers" :key="index"><div>{{head.text}}</div>
          <div>
            <v-select :items="items" placeholder="select from items"></v-select>
          </div>
        </th>
      </template>
    </v-data-table>
  </v-app>
</div>

th {
  min-width: 250px;
}


new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data () {
    return {
      items: [
        "dessert",
        "calories",
        "iron",
        "fat"
      ],
      headers: [
        {
          text: 'Dessert (100g serving)',
          align: 'start',
          sortable: false,
          value: 'name',
        },
        { text: 'Calories', value: 'calories' },
        { text: 'Fat (g)', value: 'fat' },
        { text: 'Carbs (g)', value: 'carbs' },
        { text: 'Protein (g)', value: 'protein' },
        { text: 'Iron (%)', value: 'iron' },
        { text: 'Calories', value: 'calories' },
        { text: 'Fat (g)', value: 'fat' },
        { text: 'Carbs (g)', value: 'carbs' },
        { text: 'Protein (g)', value: 'protein' },
        { text: 'Iron (%)', value: 'iron' },
      ],
      desserts: [
        {
          name: 'Frozen Yogurt',
          calories: 159,
          fat: 6.0,
          carbs: 24,
          protein: 4.0,
          iron: '1%',
        },
        {
          name: 'Ice cream sandwich',
          calories: 237,
          fat: 9.0,
          carbs: 37,
          protein: 4.3,
          iron: '1%',
        },
        {
          name: 'Eclair',
          calories: 262,
          fat: 16.0,
          carbs: 23,
          protein: 6.0,
          iron: '7%',
        },
        {
          name: 'Cupcake',
          calories: 305,
          fat: 3.7,
          carbs: 67,
          protein: 4.3,
          iron: '8%',
        },
        {
          name: 'Gingerbread',
          calories: 356,
          fat: 16.0,
          carbs: 49,
          protein: 3.9,
          iron: '16%',
        },
        {
          name: 'Jelly bean',
          calories: 375,
          fat: 0.0,
          carbs: 94,
          protein: 0.0,
          iron: '0%',
        },
        {
          name: 'Lollipop',
          calories: 392,
          fat: 0.2,
          carbs: 98,
          protein: 0,
          iron: '2%',
        },
        {
          name: 'Honeycomb',
          calories: 408,
          fat: 3.2,
          carbs: 87,
          protein: 6.5,
          iron: '45%',
        },
        {
          name: 'Donut',
          calories: 452,
          fat: 25.0,
          carbs: 51,
          protein: 4.9,
          iron: '22%',
        },
        {
          name: 'KitKat',
          calories: 518,
          fat: 26.0,
          carbs: 65,
          protein: 7,
          iron: '6%',
        },
      ],
    }
  },
})

Your assistance is highly appreciated.

Answer №1

The solution to this problem was resolved by incorporating the attach prop into the code.

Visit this link for more details

<v-select attach :items="items" placeholder="select from items"></v-select>

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

Using assets in data property or methods in Vue 3 with Vite - how to efficiently manage and access resources

Recently delving into Vue 3 and vite, I've encountered a peculiar issue during production build. In development, everything runs smoothly but when I switch to production, the assets defined in the data property are inexplicably ignored, leading to a 4 ...

What is the best way to position my image in the center within a blank canvas?

What is the best way to center an image in a white space? I am working with HTML, PHP, and CSS, but I am unsure of how to achieve this. So far, I have tried aligning the image within text on w3schools.com, but my other attempts like: #image { margin- ...

Guide on inserting an item into a vertical navigation menu

When it comes to creating a vertical menu, I rely on Bootstrap 5. https://i.sstatic.net/8CWYK.png The issue I'm facing is how to add a black background to the top of the left menu. https://i.sstatic.net/yoEcO.png I am unsure whether I should imple ...

CSS - Adding a Distinctive "Line" to a Navigation Bar

I am attempting to design a unique navbar layout with two "lines". The first line should consist of several links, while the second line would include an HTML select field with a submit button. The following code will generate the desired navbar visual ou ...

Looking to design an interactive grid for generating dynamic thumbnails

I am a beginner in the field of web development and I have a desire to create a website for showcasing my portfolio. This website should feature project thumbnails along with brief descriptions, all of which should be displayed dynamically. Although I poss ...

Arrange containers into a tower?

Currently, I am exploring the concept of stacking boxes. While I have a solid grasp on how to stack them vertically from top to bottom, I find myself puzzled about how to stack them horizontally. Check out my vertical stacking method here See how I a ...

Ways to customize the default home icon

My current theme is Redmond, but I would like to change the color of the home icon in the breadcrumb. To achieve this, I have included the hot-sneaks theme in the pom.xml file: <dependency> <groupId>org.primefaces.themes</groupId&g ...

Tips for concealing overflowing CSS content

How can I prevent CSS content from overflowing? I am trying to display a price tag in the CSS element, but it is protruding out of my card. .content{ content:''; position: absolute; left: 309px; ...

What is the best way to display table headers for each record on mobile devices? Is there a way to create a stacked view

I recently started working with bootstrap, specifically version 3. I am currently trying to find a way to create a layout that resembles a regular table when viewed on desktop but switches to a stacked format on mobile devices. This is the design I am aim ...

Arrange two divs next to each other on the page: the div on the right can be scrolled through, while the div on the

I am attempting to create a layout similar to this https://i.sstatic.net/Y1FCp.png My goal is to: Have two main divs positioned side by side inside a wrapper div Ensure the wrapper expands to fill 100% of the browser size The left div (banner) should b ...

Establish a Vue application to run on Nginx at port 80 in Raspbian, paired with a Flask backend operating on port 8080

My setup involves Nginx running a Flask-based backend on port 8080 with the following configuration: server { listen 8080 default_server; listen [::]:8080; root /var/www/html; server_name _; location /static { alias /var/www ...

Steps to apply V-model to elements

I am currently facing an issue with giving dynamically created input fields dynamic v-models from JSON data using vue.js. Here's what I'm doing: new Vue({ el: '#app', data() { return { totalAmt: 500, paymentMode: ...

Can you tell me the exact location of the authentic Quasar SSR Express Server?

I am currently working on a project using Quasar and Vue.js, and I want to integrate a MongoDB API with an Express server. In the "/ssr-src/" directory, there is an "index.js" file that contains basic routing for the Express app: /* * This file runs in a ...

Adding numerous pieces of data into the Shopware 6 database through the use of the Administration for handling Many

I recently developed a plugin within the administration of Shopware 6 and I am encountering an issue while trying to insert multiple products associated with vehicles into the database. The specific problem arises when attempting to add '92961afbc50e4 ...

Not all properties are affected by the CSS stylesheet

Even though my CSS stylesheet successfully changes the background color of the page, I am facing issues with other properties that I have set on my HTML tags. {% block body %} <div id='title'> <h1> VISUALIZER2D ...

Incorporate extra padding for raised text on canvas

I have a project in progress where I am working on implementing live text engraving on a bracelet using a canvas overlay. Here is the link to my code snippet: var first = true; startIt(); function startIt() { const canvasDiv = document.getElement ...

Issue with axios authentication failure

I have successfully implemented Kong for basic authentication on my API. It is functioning perfectly when tested with Postman. However, I am encountering an error when trying to integrate it into my app using axios. Can anyone provide some assistance? Than ...

Progress Bars Installation

For more detailed information, visit: https://github.com/rstacruz/nprogress After linking the provided .js and .css files to my main html file, I am instructed to "Simply call start() and done() to control the progress bar." NProgress.start(); NProgress. ...

What's the best way to position the <li> element beneath the hamburger icon?

Is there a way to place the list element 'Home' below the hamburger icon and logo in Bootstrap 4 in mobile mode? I attempted to display the logo as style="display: block" with no success. <div class="container"> <nav class="navbar nav ...

Creating customized meta tags with Vue Meta 3: A step-by-step guide

Just wanted to share my experience: "I decided to switch from vue-meta to @vueuse/head package found at npmjs.com/package/@vueuse/head and it works perfectly." I've implemented Vue Meta 3 for providing meta data to my website. The API documentation c ...