Skip to content

Commit

Permalink
Merge pull request #17219 from Indragith20/patch-1
Browse files Browse the repository at this point in the history
Fix #17218
  • Loading branch information
cetincakiroglu authored Dec 26, 2024
2 parents 6ff3103 + f7950d9 commit ee22fbd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/primeng/src/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ export class Select extends BaseComponent implements OnInit, AfterViewInit, Afte
}

if (this.selectedOptionUpdated && this.itemsWrapper) {
let selectedItem = <any>findSingle(this.overlayViewChild?.overlayViewChild?.nativeElement, 'li.p-highlight');
let selectedItem = <any>findSingle(this.overlayViewChild?.overlayViewChild?.nativeElement, 'li.p-select-option-selected');
if (selectedItem) {
scrollInView(this.itemsWrapper, selectedItem);
}
Expand Down Expand Up @@ -1535,7 +1535,7 @@ export class Select extends BaseComponent implements OnInit, AfterViewInit, Afte

onOverlayAnimationStart(event: AnimationEvent) {
if (event.toState === 'visible') {
this.itemsWrapper = <any>findSingle(this.overlayViewChild?.overlayViewChild?.nativeElement, this.virtualScroll ? '.p-scroller' : '.p-dropdown-items-wrapper');
this.itemsWrapper = <any>findSingle(this.overlayViewChild?.overlayViewChild?.nativeElement, this.virtualScroll ? '.p-scroller' : '.p-select-list-container');
this.virtualScroll && this.scroller?.setContentEl(this.itemsViewChild?.nativeElement);

if (this.options && this.options.length) {
Expand All @@ -1545,8 +1545,7 @@ export class Select extends BaseComponent implements OnInit, AfterViewInit, Afte
this.scroller?.scrollToIndex(selectedIndex);
}
} else {
let selectedListItem = findSingle(this.itemsWrapper, '.p-dropdown-item.p-highlight');

let selectedListItem = findSingle(this.itemsWrapper, '.p-select-option.p-select-option-selected');
if (selectedListItem) {
selectedListItem.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
Expand Down

0 comments on commit ee22fbd

Please sign in to comment.