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

Add key prop to NclistItem to re-render conversation with the appropr… #10589

Merged

Conversation

DorraJaouad
Copy link
Contributor

☑️ Resolves

Sometimes ( not sure what the trigger is yet), the active conversation class gets passed to all conversation items in the virtual scroller one by one successively.

Adding a key prop to NcListItem will force proper re-render.

🚧 Tasks

  • code review

@Antreesy
Copy link
Contributor

Antreesy commented Sep 26, 2023

Was lucky to capture the screencast (at 00:06):

Screencast.from.26.09.2023.11.30.26.webm

Happens mostly around the active conversation component, active state is handled via <RouterLink/>

Also wanted to note, that we have duplicated hidden conversation items in the list. To check:

document.querySelectorAll('.conversation-item').forEach(item => console.log(item.getAttribute('data-nav-id')))

Not happening for the Demo component:
https://vue-virtual-scroller-demo.netlify.app/recycle

document.querySelectorAll('.td.index').forEach(item => console.log(item.textContent))

Not sure, that a force-rerendering with :key will help with performance. Furthermore, maybe it's hidden conversations that triggering it, cc @ShGKme for some thoughts

@ShGKme
Copy link
Contributor

ShGKme commented Sep 26, 2023

Was lucky to capture the screencast:

Was it uploaded correctly? I see only this static image in the video...
image

Anyway, is there a way to reproduce the bug? So we can debug it to find what causes the problem. Or at least a screenshot with a bug =D

Not sure, that a force-rerendering with :key will help with performance. Furthermore, maybe it's hidden conversations that triggering it, cc @ShGKme for some thoughts

As NcListItem doesn't have any local state (except NcAvatar which already has a key, unfortunately), it won't break anything. But it makes scrolling a less performance. Component instances are not reused anymore but are fully re-created (including DOM elements) during the scrolling.

@DorraJaouad
Copy link
Contributor Author

DorraJaouad commented Sep 26, 2023

Pause on 0:05

glitching142016.mp4

@ShGKme
Copy link
Contributor

ShGKme commented Sep 26, 2023

Yep, I can see the problem now. Though, still cannot reproduce it...

@ShGKme
Copy link
Contributor

ShGKme commented Sep 26, 2023

Furthermore, maybe it's hidden conversations that triggering it

Having duplicated IDs is also weird. but it should not trigger an active state change. Vue Router adds an active state to all active links even if there are many.

…iate class

Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
@DorraJaouad
Copy link
Contributor Author

Tested when switching to filters as the glitching is also visible there.

With key Without key
With-Key Without-key

Copy link
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still cannot reproduce to debug, let's go with the key for now

@DorraJaouad DorraJaouad force-pushed the fix/noid/solve-class-glitching-in-virtualScroller branch from e5fe899 to 4921677 Compare October 17, 2023 11:35
@DorraJaouad DorraJaouad merged commit 6de7100 into master Oct 17, 2023
35 checks passed
@DorraJaouad DorraJaouad deleted the fix/noid/solve-class-glitching-in-virtualScroller branch October 17, 2023 12:01
@nickvergessen
Copy link
Member

Also fixes #10698 ?

If so we should backport this to stable27?

@ShGKme
Copy link
Contributor

ShGKme commented Oct 17, 2023

Also fixes #10698 ?

If so we should backport this to stable27?

Yes.

The problem with titles is caused by the direct DOM mutation here:

if (titleSpan && titleSpan.offsetWidth < titleSpan.scrollWidth) {
titleSpan.setAttribute('title', value)
}

Vue is not aware of this change and doesn't update the title because it is not bind to the application state.

key fix this indirectly by destroying and creating a DOM node from scratch.

@nickvergessen
Copy link
Member

/backport to stable27

@nickvergessen
Copy link
Member

/backport to stable27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants