Skip to content

Commit

Permalink
Merge pull request #15477 from robGardiner01/pick-list-focus-fix
Browse files Browse the repository at this point in the history
Fix PickList element selection problem after filtering with ScrollBar
  • Loading branch information
cetincakiroglu authored May 8, 2024
2 parents a5471a9 + 4de97a6 commit 6f95a83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/components/picklist/picklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1326,11 +1326,12 @@ export class PickList implements AfterViewChecked, AfterContentInit {
let listElement = this.getListElement(listType);
const selectedFirstItem = DomHandler.findSingle(listElement, 'li.p-picklist-item.p-highlight') || DomHandler.findSingle(listElement, 'li.p-picklist-item');
const findIndex = ObjectUtils.findIndexInList(selectedFirstItem, listElement.children);

this.focused[listType === this.SOURCE_LIST ? 'sourceList' : 'targetList'] = true;
const index = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : selectedFirstItem ? findIndex : -1;

this.changeFocusedOptionIndex(index, listType);
const sourceIndex = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : selectedFirstItem ? findIndex : -1;
const filteredIndex = this.findIndexInList(this.source[sourceIndex], this.visibleOptionsSource);

this.changeFocusedOptionIndex(filteredIndex, listType);
this.onFocus.emit(event);
}

Expand Down

0 comments on commit 6f95a83

Please sign in to comment.