primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.9k stars 1.05k forks source link

AutoComplete: VirtualScroller Panel Height #6722

Open fufupati opened 5 months ago

fufupati commented 5 months ago

Describe the bug

When VirtualScroller is used with AutoComplete and it is filtered for one value, the panel will stay constant height showing that one element which is not the behaviour I would expect.

Reproducer

https://stackblitz.com/edit/ccm4re?file=src%2FApp.jsx

PrimeReact version

10.6.6

React version

17.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

Type the exact name of one of the element inside the AutoComplete, then the panel height will stay the same despite there being only one element.

Expected behavior

The expected behaviour would be similar to the Dropdown panel's behaviour.

fufupati commented 5 months ago

I think that the problem originates from the VirtualScroller component itself, more specifically the calculateAutoSize() function.

Also I've found another bug, in the autocomplete with virtualscroller (test it in the reproducer link i provided) if you open the dropdown and scroll down a lot, then type in the autocomplete input field an item name that only occurs once in the items, in this example "Item #0", it will become buggy and wont show any elements. I think this can be fixed by putting a scrollTo({top: 0, left:0}) inside the init function.

melloware commented 5 months ago

PR is welcome!