Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: moveRight/moveLeft transferring only half of items after "Select All" #17030

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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
20 changes: 12 additions & 8 deletions packages/primeng/src/picklist/picklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,9 @@ export class PickList extends BaseComponent implements AfterViewChecked, AfterCo

moveRight() {
if (this.selectedItemsSource && this.selectedItemsSource.length) {
for (let i = 0; i < this.selectedItemsSource.length; i++) {
let selectedItem = this.selectedItemsSource[i];
let itemsToMove = [...this.selectedItemsSource];
for (let i = 0; i < itemsToMove.length; i++) {
let selectedItem = itemsToMove[i];
if (findIndexInList(selectedItem, this.target) == -1) {
this.target?.push(this.source?.splice(findIndexInList(selectedItem, this.source), 1)[0]);

Expand All @@ -1288,13 +1289,14 @@ export class PickList extends BaseComponent implements AfterViewChecked, AfterCo
}

this.onMoveToTarget.emit({
items: this.selectedItemsSource
items: itemsToMove
});

if (this.keepSelection) {
this.selectedItemsTarget = [...this.selectedItemsTarget, ...this.selectedItemsSource];
this.selectedItemsTarget = [...this.selectedItemsTarget, ...itemsToMove];
}

itemsToMove = [];
this.selectedItemsSource = [];

if (this.filterValueTarget) {
Expand Down Expand Up @@ -1337,8 +1339,9 @@ export class PickList extends BaseComponent implements AfterViewChecked, AfterCo

moveLeft() {
if (this.selectedItemsTarget && this.selectedItemsTarget.length) {
for (let i = 0; i < this.selectedItemsTarget.length; i++) {
let selectedItem = this.selectedItemsTarget[i];
let itemsToMove = [...this.selectedItemsTarget];
for (let i = 0; i < itemsToMove.length; i++) {
let selectedItem = itemsToMove[i];
if (findIndexInList(selectedItem, this.source) == -1) {
this.source?.push(this.target?.splice(findIndexInList(selectedItem, this.target), 1)[0]);

Expand All @@ -1349,13 +1352,14 @@ export class PickList extends BaseComponent implements AfterViewChecked, AfterCo
}

this.onMoveToSource.emit({
items: this.selectedItemsTarget
items: itemsToMove
});

if (this.keepSelection) {
this.selectedItemsSource = [...this.selectedItemsSource, ...this.selectedItemsTarget];
this.selectedItemsSource = [...this.selectedItemsSource, itemsToMove];
}

itemsToMove = [];
this.selectedItemsTarget = [];

if (this.filterValueSource) {
Expand Down