p-multiselect with virtualScroll shows empty list after reopening until scroll is triggered
Describe the bug
When virtualScroll is enabled in the p-multiselect component (and possibly p-select as well), after selecting one or more elements and closing the component, reopening it shows an empty list. The items only appear after the user manually scrolls the list.
This issue affects the user experience as it gives the impression that the options have disappeared or that something is broken in the component.
Pull Request Link
No response
Reason for not contributing a PR
- [ ] Lack of time
- [x] Unsure how to implement the fix/feature
- [ ] Difficulty understanding the codebase
- [ ] Other
Other Reason
No response
Reproducer
https://stackblitz.com/edit/wbxnfrkb
Environment
Windows 11 Enterprise Version 24H2 (OS Build 26100.7171)
Angular version
20.3.13
PrimeNG version
v20
Node version
22.21.1
Browser(s)
Chrome Version 142.0.7444.176
Steps to reproduce the behavior
- Open the reproducer link: https://stackblitz.com/edit/wbxnfrkb
- Expand the
p-multiselectcomponent (the list of elements displays correctly) - Select one or more elements from the list
- Close the dropdown component
- Reopen the dropdown component
- BUG: The list appears empty - no items are visible
- Scroll the list manually
- WORKAROUND: Items become visible after scrolling
Expected behavior
When reopening the p-multiselect component with virtualScroll enabled, all items should be visible immediately without requiring the user to scroll first. The component should maintain the correct scroll position or properly render the visible items in the virtual scroll viewport.
https://github.com/primefaces/primeng/issues/19078
Thank you for sharing the ticket szlezakbartosz
Hello, if this helps, I started a discussion with a solution that works for TreeSelect with the same issues as MultiSelect. But I never received a response from them
If you are interested https://github.com/orgs/primefaces/discussions/4365