Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/primeng/src/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ export class MultiSelect extends BaseEditableHolder<MultiSelectPassThrough> {

onOptionMouseEnter(event, index) {
if (this.focusOnHover) {
this.changeFocusedOptionIndex(event, index);
this.focusedOptionIndex.set(index);
}
}

Expand Down Expand Up @@ -2007,7 +2007,7 @@ export class MultiSelect extends BaseEditableHolder<MultiSelectPassThrough> {
}

partialSelected() {
return this.selectedOptions && this.selectedOptions.length > 0 && this.selectedOptions.length < (this.options?.length || 0);
return this.hasSelectedOption() && !this.allSelected();
}

/**
Expand Down Expand Up @@ -2052,12 +2052,14 @@ export class MultiSelect extends BaseEditableHolder<MultiSelectPassThrough> {

if (this.options && this.options.length) {
if (this.virtualScroll) {
const selectedIndex = this.modelValue() ? this.focusedOptionIndex() : -1;
const selectedIndex = this.modelValue() ? this.findSelectedOptionIndex() : -1;
if (selectedIndex !== -1) {
this.scroller?.scrollToIndex(selectedIndex);
setTimeout(() => {
this.scroller?.scrollToIndex(selectedIndex);
}, 20);
}
} else {
let selectedListItem = findSingle(this.itemsWrapper, '[data-pc-section="option"][data-p-selected="true"]');
let selectedListItem = findSingle(this.itemsWrapper, '[data-p-selected="true"]');

if (selectedListItem) {
selectedListItem.scrollIntoView({ block: 'nearest', inline: 'nearest' });
Expand Down
4 changes: 2 additions & 2 deletions packages/primeng/src/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ export class Select extends BaseInput<SelectPassThrough> implements AfterViewIni

onOptionMouseEnter(event, index) {
if (this.focusOnHover) {
this.changeFocusedOptionIndex(event, index);
this.focusedOptionIndex.set(index);
}
}

Expand Down Expand Up @@ -1419,7 +1419,7 @@ export class Select extends BaseInput<SelectPassThrough> implements AfterViewIni

if (this.options && this.options.length) {
if (this.virtualScroll) {
const selectedIndex = this.modelValue() ? this.focusedOptionIndex() : -1;
const selectedIndex = this.modelValue() ? this.findSelectedOptionIndex() : -1;
if (selectedIndex !== -1) {
setTimeout(() => {
this.scroller?.scrollToIndex(selectedIndex);
Expand Down