Search code examples
angularprimengprimeng-dropdownsangular-cdk-virtual-scroll

PrimeNG dropdown with virtual scroll not keeping selection in view


I am making use of the PrimeNG drop down component with custom filtering and virtual scroll enabled.

I am finding the component is not scrolling back to the last selection made in the list of items in view when it's re-opened, instead it just scrolls back to the top of the list meaning you have to physically scroll to go find the selection made.

See this example stackblitz

I did come across a solution here that talks about calling scrollToIndex on a CdkVirtualScrollViewport instance which sound like it could be of use for me. But when I attempted to incorporate this in my code, my instance variable comes up as undefined.

Does anyone know what the correct approach is here? I am using PrimeNG 7.1.3.

Thanks


Solution

  • This is due to this issue which has been solved in version 8.0.1 with this PR. So upgrade primeng to resolve this issue.

    I have also opened another issue stating further issues relating to keeping the selected item in view, and proposed a fix PR, when this PR is merged all issues to keep the selection in view will be resolved.