Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child element order not maintained with v-if #608

Closed
danny1461 opened this issue Feb 18, 2020 · 6 comments
Closed

Child element order not maintained with v-if #608

danny1461 opened this issue Feb 18, 2020 · 6 comments

Comments

@danny1461
Copy link

Version

2.4.0

Reproduction link

https://play.nativescript.org/?template=play-vue&id=2rEhAr

Platform and OS info

Android

Steps to reproduce

When actions are taken to cause a re-render of a page, elements that were previously hidden by v-if are appended to the parent at the wrong location.

What is expected?

Order of the elements from the source code should be preserved even as the data causing the re-renders changes.

What is actually happening?

It appears that a basic remove/append operation is occurring; so elements being brought into existence are appearing at the end of the container instead of where they are in the source template.


This is the same minimal production code in Vue for web. Note that the last button remains the last button always.

https://codesandbox.io/s/jovial-bash-fq8by

@rigor789
Copy link
Member

I have seen this before, but I can't remember being able to track down the issue. However, there is a workaround that seems to solve it by using v-else-if or v-else: https://play.nativescript.org/?template=play-vue&id=2rEhAr&v=2

This might not be a solution in all cases, but worth giving it a try.

@danny1461
Copy link
Author

That definitely does work and helps me move past my current issue in this case. Now the log shows "InsertBefore" for that element and it appears where it should.

@teddysasmita
Copy link

teddysasmita commented May 23, 2020

StackLayout is not rendering its children in the right order in 2.6.2.

@rigor789
Copy link
Member

rigor789 commented May 23, 2020

@teddysasmita mind sharing an example?

Edit: found the issue - have a fix just testing it to make sure everything works!

Edit 2: Fixed in 2.6.3

rigor789 added a commit that referenced this issue May 23, 2020
@teddysasmita
Copy link

I am sorry for the late response. Below is the code that I used.
The performance is indeed increase. Thank you so much for all the great works.

Masuk Daftar Sbg Tamu .

@nativescript-vue-bot
Copy link
Collaborator

We are locking this issue because it has been closed for more than 14 days.

If the issue comes up again please open a new issue with additional details.

@nativescript-vue nativescript-vue locked as resolved and limited conversation to collaborators Jun 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants