Issues encountered when using Vue Transition in conjunction with v-autocomplete

Attempting to conditionally display or hide a selection text field using Vue's Transition feature, but experiencing an issue where the text field appears and disappears without any transition effect.

<template>
  <Transition
    v-if="isActive"
    name="fade"
  >
    <v-autocomplete
      :items="[1,2,3]"
    ></v-autocomplete>
  </Transition>
</template>

<script setup>
import { ref } from 'vue'
const isActive = ref(false); // This will be toggled in a different location of the code
</script>


<style scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>

Various attempts have been made, such as placing the v-if on the v-autocomplete component instead of the Transition, yet the desired behavior is not achieved. An example can be seen on Vuetify Playground

Inquiring about what could be going wrong with my approach. If achieving this behavior through Transition is not viable, seeking alternative methods to attain the same outcome.

Answer №1

You might want to include the v-if in the first child element, not in the Transition component.

<Transition name="fade">
  <v-autocomplete
    v-if="isActive"
    :items="[1,2,3]"
  ></v-autocomplete>
</Transition>

const { createApp, ref } = Vue
const { createVuetify } = Vuetify

const vuetify = createVuetify()

const app = createApp({
  setup() {
    const isActive = ref(true)
    
    return { isActive }
  }
})
app.use(vuetify).mount('#app')
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ff9faeafbe6e9f6cfbca1bca1be">[email protected]</a>/dist/vuetify.min.css">

<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="addbd8c8ed9e839e8399">[email protected]</a>/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7a1a2b2a3beb1ae97e4f9e4f9e6">[email protected]</a>/dist/vuetify.min.js"></script>

<div id="app">
  <v-btn @click="isActive = !isActive">Toggle</v-btn>
  <Transition name="fade">
    <v-autocomplete
      v-if="isActive"
      :items="[1,2,3]"
    ></v-autocomplete>
  </Transition>
</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

Issues with special characters in @font-face rules

For some reason, I'm encountering issues with the CSS3 property @font-face in certain browsers when trying to use my own fonts. Chrome, Safari, and IE10 work fine, but other browsers present several problems: The code I used looks like this: (fonts G ...

Resizing svg to accommodate a circle shape

As I work on my vue.js app that involves a plethora of diverse icons, I made the decision to create a small icons builder in node.js. The purpose is to standardize their usage and also "crop" each SVG so it fits perfectly within its parent container by uti ...

The Axios POST request is not being properly parsed within a Python Flask application

Introduction Greetings! I have noticed that this particular question has been asked several times, but a suitable solution seems to be lacking. The Issue at Hand While GET requests are functioning as expected, there seems to be a problem when attempting ...

Modifying an HTML list item to become 'active' in a navigation bar

One way I've been implementing my navbar on each page is by using the following code at the bottom of the page within script tags: $("#navbar-partial").load("navbar.html). The code for the navbar list looks like this: <ul id="main-nav" class="nav ...

Modify table row background color using PHP based on its position in the table with the use of a function

I am having trouble formatting my table to highlight different rows in distinct colors. The top row should be one color, the second row another, and the bottom two rows a different color each. This is to represent winners, teams getting promoted, and tho ...

Transitioning to mui5's sx prop instead of makeStyles is generating a typescript error - none of the overloads match this call when passing an object with

I encountered an issue while converting a component to mui 5. Here is the original code snippet: const useStyles = makeStyles({ imageContainer: { display: "flex", width: "65%", float: "left", marginRight ...

Vue.js and Parse Server do not allow for the retrieval of the insecure header "x-parse-job-status-id"

For several months, everything was running smoothly without any issues. However, now when attempting to log in, an error is occurring. The code provided here is a simplified version where the error occurs at the "Parse.User.logIn" line. Previous similar ...

Adding flair to the selected element in the HTML nav bar

I was attempting to customize the appearance of the active item within an HTML navigation bar, which corresponds to the a element. To test this out, I used the example from Here is my modified code, where I introduced a new class "active" and applied the ...

Can a Vue computed property return a promise value?

I have a specific computed property in my code that triggers an API request and retrieves the required data: async ingredients() { const url = "/api/ingredients"; const request = new Request(url, { method: "GET", credentials: "same-or ...

How to place a circle below text using CSS

I'm attempting to center a 5px x 5px circle under the links in a navigation bar to indicate the current page, but I'm uncertain about how to achieve this effect. Here is the current outcome: Link to Image This is what I aspire to accomplish: Li ...

scrollable header within the confines of the container

I have been trying to find a solution for my scrolling issue, but I just can't seem to get it right. I want the content within a div to scroll inside its container without affecting the header. Here's the updated JSFiddle link with the jQuery cod ...

Changing the CSS property of a single table cell's innerHTML

I have a question that may seem silly, but I'm going to ask it anyway. Currently, I am iterating through a list of strings that follow the format "1H 20MIN" and adding them to table cells using the innerHTML property like so: for (i = 0; i < list ...

What is the process for uninstalling Vue CLI 2 from my system?

I am looking to start a new vue project using @vue/cli . It seems that the vue/cli has been updated to version 3. The documentation I found is located at and I am currently running ubuntu 17.10, attempting to uninstall vue-cli using npm uninstall vue-cl ...

The issue of duplicate CSS arising during the compilation of SASS into a single CSS file with G

Just getting started with Stack Overflow and Gulp (using version 3.9.1). My goal is to compile all of my scss files into a single css file for my website. Here's what I have in my gulpfile so far: var gulp = require('gulp'); var sass = requ ...

Padding-left may cause text to not wrap correctly

Every link in the left menu has a padding-left: 15px;. This is done to accommodate a background image (the blue arrow). However, when text wraps (like in "Paintings, prints, and watercolours"), it seems to ignore the padding. I've searched extensive ...

Automated scrolling within a div when an li element overflows

Looking to implement automatic scrolling in a div. I have a list of elements within a fixed height div, and now I want the div to scroll automatically when I press the down key after highlighting the 3rd li element (i.e Compt0005). Can anyone help me solve ...

Vuetify is having trouble finding the component

After reviewing similar questions labeled as duplicate, I found that none of them provide a solution to my issue. Currently, while using Vuetify, I am encountering the error message 'Failed to resolve component': /** * main.ts * * Bootstraps ...

Insider's guide to showcasing code in vibrant colors using Python Django

Context: I am currently working on a Python Django web application and need to showcase code snippets in the browser with syntax highlighting. An example of the code snippet I want to display would be: if True: print("Hello World") I am look ...

Element sticking on scroll down and sticking on scroll up movements

I am currently working on a sticky sidebar that catches and stays fixed at a certain scroll point using JavaScript. However, I am facing an issue where I need the sidebar to catch when scrolling back up and not go further than its initial starting point. ...

Methods for animating .jpg images using CSS

I'm currently working on animating an image, specifically moving it from left to right and back. However, before I dive into implementing CSS animation keyframes, I noticed that I am having trouble getting the HTML element to follow the CSS styles I a ...