[19600] fix: Scroll behavior on hover and open, fix partialSelected with groups - #19601
Open
fkwq34 wants to merge 1 commit into
Open
[19600] fix: Scroll behavior on hover and open, fix partialSelected with groups#19601fkwq34 wants to merge 1 commit into
fkwq34 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes: #19600
Description
This PR fixes several issues in Select and MultiSelect components related to scroll behavior and partial selection state.
Issues Fixed
1. Hover causes unwanted scroll jumping
When hovering over options in Select/MultiSelect dropdowns with virtual scroll, the list would unexpectedly jump/scroll.
Root cause:
onOptionMouseEnterwas callingchangeFocusedOptionIndex(), which triggersscrollInView().Fix: Changed
onOptionMouseEnterto directly setfocusedOptionIndexfor visual styling without triggering scroll.2. Dropdown not scrolling to selected item on open
When reopening a Select/MultiSelect with virtual scroll, it would sometimes show the wrong position or not scroll to the selected item.
Root cause: Was using
focusedOptionIndex()(which could be changed by hover) instead of the actual selected item index.Fix: Use
findSelectedOptionIndex()when determining scroll position on overlay open, with proper timing for virtual scroller initialization.3. MultiSelect
partialSelected()broken with grouped optionsWhen using grouped options with a custom header checkbox template, the indeterminate state would disappear after selecting items.
Root cause:
partialSelected()comparedselectedOptions.lengthwithoptions.length, butoptionsincludes group objects when using groups.Fix: Changed
partialSelected()to usehasSelectedOption() && !allSelected()which properly handles groups.Steps to Reproduce
Issue 1 & 2:
[virtualScroll]="true"and many optionsIssue 3:
[group]="true"and customheaderCheckboxIconTemplateExpected Behavior
partialSelected()should returntruewhen some (but not all) selectable items are selected, regardless of groupingFiles Changed
packages/primeng/src/select/select.tspackages/primeng/src/multiselect/multiselect.ts