[BUG] - Autocomplete section overlap due to incorrect `itemHeight` with virtualization
NextUI Version
2.6.11
Describe the bug
AutocompleteSection, when containing too many AutocompleteItems, seems to have the category text (and occasional items) overlap. This behaviour is pertinent to all tested major browsers (Chromium-based browsers, Safari, Firefox).
Your Example Website or App
https://stackblitz.com/~/github.com/thatkev/autocomplete-bug https://github.com/thatkev/autocomplete-bug
Steps to Reproduce the Bug or Issue
- Start dev server, visit the root page.
- Click the dropdown, scroll and observe the bug.
Expected behavior
I expect that AutocompleteSection and AutocompleteItem are appropriately spaced, and do not overlap.
Screenshots or Videos
Operating System Version
macOS Sequoia 15.3 Beta (24D5034f)
Browser
Chrome
@wingkwong please check
Issue cause has been pinpointed to virtualization- disabling it resolves the issue.
@jrgarciadev Please assign it to me!
The issue occurs because an incorrect itemHeight is being passed during virtualization.
https://github.com/heroui-inc/heroui/blob/a1cc37888747a551d9dc5b2f53a1d32d839d2553/packages/components/autocomplete/src/use-autocomplete.ts#L460-L464
Since startContent dynamically changes the list height, the correct itemHeight must be provided.
https://github.com/user-attachments/assets/e6124c4e-081f-43c3-932b-817a7a511175
I’ll update the docs to note that startContent with virtualization requires the correct itemHeight.
Just a side note, I also tried dynamically measuring the list item height and applying it to the virtualizer, but it didn’t work as expected... 😓
@ryo-manba What if not all items have startContent? Won’t this throw off the formatting?
As it stands, the only option is to set isVirtualized={false}.