primefaces / primereact

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

AutoComplete: panel height should fit items when using virtual scrolling #7237

Open inad9300 opened 2 months ago

inad9300 commented 2 months ago

Describe the bug

Enabling virtual scrolling in <AutoComplete /> has the following undesired side effect: image

Compare with the behavior without virtual scrolling: image

Reproducer

https://primereact.org/autocomplete/#virtualscroll

System Information

System:
    OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 2.24 GB / 15.40 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
  Browsers:
    Chrome: 129.0.6668.58
  npmPackages:
    primereact: 10.6.6 => 10.8.3 
    react: 18.2.0 => 18.2.0
blan19 commented 2 months ago

AutoComplete component's Virtual Scroll internally uses VirtualScroller component.

if (props.virtualScrollerOptions) {
  // ... rest
  return <VirtualScroller ref={props.virtualScrollerRef} {...virtualScrollerProps} pt={_ptm('virtualScroller')} __parentMetadata={{ parent: props.metaData }} />;
}

Size of the viewport is configured usingscrollWidth, scrollHeight properties directly or with CSS width and height styles.

VirtualScroller component appears to maintain a fixed size regardless of the number of items

therefore, I am not certain whether this is a bug or not..

@melloware

to achieve the behavior intended in issue, it seems that modifications to VirtualScroller component might be necessary

however, considering the many components that use VirtualScroller, I'm not certain if this is the right approach..

If not, another option could be to update the documentation to inform users that resizing is not supported

thank you xD

melloware commented 2 months ago

Agreed the VirtualScroller is used throughout the library and three are various bugs reported against it but its a PrimeTek core component they use in many libraries so I am hestitant to touch it. I usually leave VirtualScroller issues to PrimeTek.