primefaces / primefaces/primereact

AutoComplete: VirtualScrolling Issues with "itemTemplate", "optionGroupLabel" and "optionGroupChildren"

Open
#3,418 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
CSS
Stars
8.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

I've encountered some issues with the AutoComplete component while virtualscrolling.

When there is an itemTemplate, optionGroupLabel and optionGroupChildren. The virtualscrolling doesn't work. While scrolling the dropdown will flicker and be reset to the very top.

During logging I found out, that all suggestions are passed to the itemTemplate function. When not using itemTemplate, optionGroupLabel and optionGroupChildren you can see that only like 12 suggestions are being passed. Also while scrolling when you log the parameter of onLazyLoad you can see that first is almost always 0 and last doesn't get higher than 1. When not using itemTemplate, optionGroupLabel and optionGroupChildren, first and last are updated normally.

I've added a codesandbox to reproduce this issue, to check the "normal" behaviour just comment the first return statement which is an array and use the second return which just uses suggestions.

I hope my description is sufficient.

Reproducer

https://codesandbox.io/s/blissful-smoke-9bjjm9?file=/src/demo/AutoCompleteDemo.js:1994-2013

PrimeReact version

8.6.1

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the AutoComplete virtual-scrolling behavior and the linked CodeSandbox at src/demo/AutoCompleteDemo.js:1994-2013. Compare the grouped itemTemplate case with the plain suggestions case, observing the itemTemplate input and onLazyLoad first/last values. Done means grouped suggestions scroll without flickering or resetting, while lazy-load ranges continue to update normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.