primereact icon indicating copy to clipboard operation
primereact copied to clipboard

Multiselect scroll position reset bug

Open KennethSJiang opened this issue 2 years ago • 6 comments

Describe the bug

After selecting an item on Multiselect that has long item list, the scroll position keeps reset to the selected item position. This is even reproducible in the latest tutorial https://primereact.org/multiselect/

Reproducer

No response

PrimeReact version

10.6.2

React version

17.x

Language

ES6

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

KennethSJiang avatar Apr 04 '24 16:04 KennethSJiang

Can confirm this is happening in version 10.6.2 of PrimeReact, but does not happen in 10.5.1.

It just constantly scrolls back up to the top of the list.

Working (10.5.1) DropdownWorking

Not Working (10.5.2 through 10.6.2) DropdownNotWorking

It looks like the bug was introduced in 10.5.2

iantrudell avatar Apr 04 '24 16:04 iantrudell

@melloware there's a half dozen issues related to this one, I think they relate to the changes/enhancements you made recently

iantrudell avatar Apr 05 '24 13:04 iantrudell

https://github.com/primefaces/primereact/commit/736a9daa8cf1a706cb07d949e078b5cdca4910f2 for now it breaks scrolling and arrow selection changeFocusedOptionIndex called scrollIntoView but scrollIntoView using data-p-highlight as selector maybe we need a data-p-focus to differentiate

kl-nevermore avatar Apr 07 '24 08:04 kl-nevermore

If I understand correctly, the scrollInView should only be executed when the panel is opened. the changeFocusedOptionIndex should be executed when hover or arrow down and up

kl-nevermore avatar Apr 07 '24 08:04 kl-nevermore

@kl-nevermore that is correct scrollInView only when panel is open and changedFocusedOptionIndex when panel is open and hover or keyboard.

melloware avatar Apr 07 '24 11:04 melloware

PR submitted. Basically on Panel open it should focus the first selected option. On Hover or keyboard it should focus the current Target.

melloware avatar Apr 07 '24 12:04 melloware