Skip to content

Dynamically loaded content messes with display #88

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

Closed
LorinIonita opened this issue Feb 28, 2019 · 6 comments
Closed

Dynamically loaded content messes with display #88

LorinIonita opened this issue Feb 28, 2019 · 6 comments
Labels

Comments

@LorinIonita
Copy link

I have a list of items that dynamically re-renders based on a filter (it retrieves the data back from an API). When the list is small (e.g. 7 items in my case) and the filter brings back 1 item, going back to the 7 items list only renders 1 item (a regular list doesn't have this issue).

Do you have any idea how I can fix this?

@tangbc
Copy link
Owner

tangbc commented Mar 3, 2019

Sorry, I can't quite understand the filter brings back 1 item, going back to the 7 items list only renders 1 item means, can you explain more?

@LorinIonita
Copy link
Author

Here is a code sandbox example
https://codesandbox.io/s/4w0xw8w514?fontsize=14

If you use the selectbox and select "two" it renders a list of 2 items. If you select "one" again, it doesn't go back to the 7 items. It just renders the first 2 items in the list.

I managed to fix it by adding a ref="list" to the virtual list and doing this.$refs.list.$forceUpdate(); after the items are returned from the api.

@tangbc
Copy link
Owner

tangbc commented Mar 5, 2019

I have reproduced it, thanks for reporting this.

@tangbc tangbc added the bug label Mar 5, 2019
@cchuang6
Copy link

cchuang6 commented Mar 6, 2019

I think the problem is if the number of remain plus the number of bench is greater than the data items, it will not re-render the list. I hot fix it by checking the size of the items is smaller than (remain + bench) and call forceUpdate if the condition is true.

Here is the hot fix example:
https://codesandbox.io/s/5yljv9548x

@tangbc
Copy link
Owner

tangbc commented Mar 7, 2019

@cchuang6 almost that, but vitrual-list shoud handle it itself, I will fix it in next version.

@tangbc
Copy link
Owner

tangbc commented Mar 9, 2019

Fixed and publish by v1.3.1.

But when change new list data, render zone start and end is still old and cannot know if this update come from new list or by scrolling, so call forceRender() after that is still necessary.

@tangbc tangbc closed this as completed Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants