Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete: Virtual Scroller incompatible with autoHighlight #2891

Closed
Syuks opened this issue May 13, 2022 · 1 comment · Fixed by #2892
Closed

Autocomplete: Virtual Scroller incompatible with autoHighlight #2891

Syuks opened this issue May 13, 2022 · 1 comment · Fixed by #2892
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@Syuks
Copy link

Syuks commented May 13, 2022

Describe the bug

If an Autocomplete component is using a virtual scroller, the autoHighlight option does not work. The first li item is no longer the overlayRef.current.firstChild.firstChild but the overlayRef.current.firstChild.firstChild.firstChild. Or the overlayRef should be replaced with the virtualScrollerRef. See: autoHighlight.

Also, when navigating through the dropdown with arrow keys, the container fails to scroll when the highlighted item is no longer in view. This issue has the same nature as the previous one, the scrollInView function uses overlayRef instead of virtualScrollerRef. Note that the whole onInputKeyDown function uses overlayRef. See: down arrow and up arrow

Reproducer

https://codesandbox.io/s/primereact-test-forked-poxorh?file=/src/index.js

PrimeReact version

8.1.0

React version

18.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. Create an Autocomplete component with autoHighlight and virtualScrollerOptions.

  2. Make the dropdown appear.

  3. See no highlight on first item.

  4. Create an Autocomplete component with virtualScrollerOptions.

  5. Make the dropdown appear.

  6. Navigate the dropdown with up and down arrow keys.

  7. See no scrolling of the container.

Expected behavior

I expect the autoHighlight option highlight the first item of an Autocomplete component that is using a virtual scroller container.

I expect the highlighted item to stay in view when navigating with the arrow keys the dropdown of an Autocomplete component using a virtual scroller.

@Syuks Syuks added the Type: Bug Issue contains a defect related to a specific component. label May 13, 2022
melloware added a commit to melloware/primereact that referenced this issue May 14, 2022
@melloware melloware self-assigned this May 14, 2022
@melloware melloware added this to the 8.2.0 milestone May 14, 2022
@melloware melloware changed the title Autocomplete: Virtual Scroller incompatible with autoHighlight and scrolling with keys Autocomplete: Virtual Scroller incompatible with autoHighlight May 14, 2022
@melloware
Copy link
Member

@Syuks I fixed the autohighlight issue but the scrollintoView is a bigger issue because the VirtualScroller has its own scrollIntoView method etc. Its quite complex so do you mind opening another ticket just for the UP and DOWN keys with VirtualScroller? That way I can fix this autoHighlight ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants