Shifting content results in Vue transitions

I've encountered an issue with transitioning content shifts. My data array is displayed in different areas of the DOM based on the state.

The main idea:


OPEN

  • feedback 1 [ complete ]
  • feedback 2 [ complete ]
  • feedback 3 [ complete ]

CLOSED


Goal: When "close" is clicked, feedback should fade out from OPEN and appear under the CLOSED section.

What I attempted: Rendering "Closed" items with a transition effect:

<transition name="fade">
  <v-row v-if="feedbackItem.state ==='closed'" v-for="feedbackItem in closedTasks" :key="feedbackItem.id">
    <p>
    {{ feedbackItem.feedback }}
    </p> 
    </v-row> 
</transition>

<style>
.fade-enter-active, .fade-leave-active {
  transition: opacity .5s;
}
.fade-enter, .fade-leave-to {
  opacity: 0;
}
</style>

However, the desired result is not achieved (no visible transition), and elements under "Closed" are hidden if there are multiple closed items. It seems related to how the computed item lists are rendered. The line

v-if="feedbackItem.state ==='closed'"
might be causing the problem. Any suggestions on how to achieve the desired outcome or what could be done differently?

Codepen link for experimentation: here.

Thank you to anyone taking a moment to help figure this out!

Answer №1

To efficiently create loops, ensure you incorporate the transition group:

<transition-group name="fade" tag="div">
  <v-row v-if="feedbackItem.state ==='closed'" v-for="feedbackItem in closedTasks" :key="feedbackItem.id">
    <p>
      {{ feedbackItem.feedback }}
    </p> 
  </v-row> 
</transition-group>

For more information, visit here.

The tag="div" is utilized as the element to enclose the item list.

Furthermore, it's recommended to avoid combining v-if and v-for as this practice can be less efficient. Instead, creating a computed property to filter the desired items for looping is advisable.

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

Dropping anchor whilst skipping or jumping

One of my website elements is a drop anchor that connects from a downwards arrow situated at the bottom of a full-page parallax image to another section on the same page. The HTML code snippet for the drop anchor is as follows: <section id="first" cla ...

How can I resolve the Vue warning about an unknown custom element <password-input>?

I've been working on resolving an error within a component, but unfortunately, I'm still encountering issues. The error message is as follows: [Vue warn]: Unknown custom element: - have you registered the component correctly? For recursive co ...

HTML Settings Menu: Customize Your Preferences

Greetings! I am currently in the process of creating a website and am seeking advice on how to approach incorporating a menu option. After researching, I discovered that the <menu> tag is not supported by major browsers, which came as a surprise. Add ...

The div element is not adjusting its size according to the content it

Essentially, I want the #main-content div to expand so that its content fits inside without overlapping, as shown in the codepen example. I've been unsuccessful in implementing the clearfix or overflow:hidden solutions so far. It's puzzling why ...

What is the best approach to retrieve a JSON object from a form exception that has a specific name?

I have a certain form with input fields. My goal is to generate a JSON object from the form, excluding any input whose name is "point". However, my code doesn't seem to be working properly when I use the "not()" function. What am I doing wrong and how ...

The usage of the "this" keyword in a function call is not

When I try to call a local function using the this pointer, I encounter an error message stating 'Uncaught TypeError: undefined is not a function'. The issue arises on line this.createtimetable(); within the loadtimetable function. The relevant ...

A guide on implementing a jQuery click function on ng-click in an AngularJS application

Currently, I am developing a mobile app and utilizing MDL for the app's UI along with Angular JS. The theme I purchased from ThemeForest is called "FAB." My goal is to display data from the server using API's and showcase all the products that ar ...

React Native not refreshing state data

I'm working with a FlatList that contains the code snippet below: <FlatList ........... refreshing={this.state.refresh} onRefresh={() => { this.setState({ ...

I am currently facing an issue with my Next JS app where the search results page is not showing up when a user enters a query

I am currently working on a search application using Next.js. Within my app directory, I have 3 main files - layout.js, page.js, and searchResults.js Here is the code in layout.js: export const metadata = { title: 'xyz Search', description: ...

A guide on Implementing PastBack Functionality with AJAX Responses

When I make a GET request for an HTML page, I come across the following element: <a id="ctl00_cphRoblox_ClaimOwnershipButton" href="javascript:__doPostBack('ctl00$cphRoblox$ClaimOwnershipButton','')">Claim Ownership</a> My ...

I am encountering an issue with Quasar Dev not functioning properly when running the "quasar dev"

Whenever I try to run quasar dev, I encounter an issue with Quasar and prefer not to proceed with the run. https://i.sstatic.net/4QC7a.png ...

Conceal the elements of Widget Style by using jQuery to target the ul

My task involves creating a widget style using HTML's ul tag. <div class='tabs' style='width:50%'> <ul> <li id="basic-li"><a href='#basic_information'>Basic</a></li> <li id="mas ...

Leveraging functions in a Node.js module

I am struggling with using a function inside a Node.js module. I have implemented a custom sorting function to sort an array of objects based on the value of a specific property. exports.getResult = function(cards) { cards.sort(sortByField('suit& ...

What is the method for accessing the Redux store content directly in the console, without using any developer tools

By utilizing React Devtools, I am able to access the store by: $r.store.getState() Is there an alternate method to retrieve the store without using React Devtools? ...

What is the best way to incorporate products as components into the cart component?

ProductCard import React from 'react'; import { Card, Container, Row, Col, Button} from 'react-bootstrap'; import Cart from './Cart'; import './ItemCard.css'; function ProductCard(props){ return( <Car ...

Click the button to reset all selected options

<form method="post" action="asdasd" class="custom" id="search"> <select name="sel1" id="sel1"> <option value="all">all</option> <option value="val1">val1</option> <option value="val2" selected="selected"> ...

Ways to retrieve the pending count of XMLHttpRequests in JavaScript

I am trying to figure out how to capture the count of pending xmlhttprequests in a web page using javascript while working with selenium and python. It seems like there is a useful link that could help me get this information, but I'm having trouble ...

Tips for setting a default checked radio button in Vuejs

Upon page load, the radio button status should initially be checked. Then, when the radio button is changed, a div below it should hide and show accordingly. I have attempted to write the code for this functionality, but unfortunately it is not working a ...

Is there a glitch with child margins in a relative-absolute positioning setup?

Could someone shed some light on how I can prevent the margin from one sibling div affecting another? The browser's layout seems a bit baffling to me in this scenario. I'm attempting to position the yellow box relative to its parent, but the pre ...

Capturing HTTP requests using JavaScript

I am looking to modify all my ajax requests by intercepting them and changing POST methods before they go out. To intercept all my ajax calls, I can do the following: $.ajaxSetup({ beforeSend: function() { alert('sending...'); } ...