Skip to content

Commit

Permalink
Fixed #10284 - Picklist events not always return an array
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Jun 4, 2021
1 parent 003d8eb commit 7ab9c64
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/app/components/picklist/picklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {ObjectUtils, UniqueComponentId} from 'primeng/utils';
<span class="p-picklist-filter-icon pi pi-search"></span>
</div>
</div>
<ul #sourcelist class="p-picklist-list p-picklist-source" cdkDropList [cdkDropListData]="source" (cdkDropListDropped)="onDrop($event, SOURCE_LIST)"
[ngStyle]="sourceStyle" role="listbox" aria-multiselectable="multiple">
<ng-template ngFor let-item [ngForOf]="source" [ngForTrackBy]="sourceTrackBy || trackBy" let-i="index" let-l="last">
Expand Down Expand Up @@ -346,7 +346,7 @@ export class PickList implements AfterViewChecked,AfterContentInit {
this.filterValueSource = query;
else if (listType === this.TARGET_LIST)
this.filterValueTarget = query;

this.filter(data, listType);
}

Expand Down Expand Up @@ -376,7 +376,7 @@ export class PickList implements AfterViewChecked,AfterContentInit {
else
return this.filterValueTarget ? (!this.visibleOptionsTarget || this.visibleOptionsTarget.length === 0) : (!this.target || this.target.length === 0);
}


isVisibleInList(data: any[], item: any, filterValue: string): boolean {
if (filterValue && filterValue.trim().length) {
Expand Down Expand Up @@ -616,19 +616,19 @@ export class PickList implements AfterViewChecked,AfterContentInit {
onDrop(event: CdkDragDrop<string[]>, listType: number) {
let isTransfer = event.previousContainer !== event.container;
let dropIndexes = this.getDropIndexes(event.previousIndex, event.currentIndex, listType, isTransfer, event.item.data);

if (listType === this.SOURCE_LIST) {
if (isTransfer) {
transferArrayItem(event.previousContainer.data, event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);

if (this.visibleOptionsTarget)
this.visibleOptionsTarget.splice(event.previousIndex, 1);
this.onMoveToSource.emit({items: event.item.data});

this.onMoveToSource.emit({items: [event.item.data]});
}
else {
moveItemInArray(event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);
this.onSourceReorder.emit({items: event.item.data});
this.onSourceReorder.emit({items: [event.item.data]});
}

if (this.filterValueSource) {
Expand All @@ -638,15 +638,15 @@ export class PickList implements AfterViewChecked,AfterContentInit {
else {
if (isTransfer) {
transferArrayItem(event.previousContainer.data, event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);

if (this.visibleOptionsSource)
this.visibleOptionsSource.splice(event.previousIndex, 1);
this.onMoveToTarget.emit({items: event.item.data});

this.onMoveToTarget.emit({items: [event.item.data]});
}
else {
moveItemInArray(event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);
this.onTargetReorder.emit({items: event.item.data});
this.onTargetReorder.emit({items: [event.item.data]});
}

if (this.filterValueTarget) {
Expand All @@ -673,7 +673,7 @@ export class PickList implements AfterViewChecked,AfterContentInit {
findFilteredCurrentIndex(visibleOptions, index, options) {
if (visibleOptions.length === index) {
let toIndex = ObjectUtils.findIndexInList(visibleOptions[index-1], options);

return toIndex + 1;
}
else {
Expand Down Expand Up @@ -753,39 +753,39 @@ export class PickList implements AfterViewChecked,AfterContentInit {
.p-picklist[${this.id}] {
flex-direction: column;
}
.p-picklist[${this.id}] .p-picklist-buttons {
padding: var(--content-padding);
flex-direction: row;
}
.p-picklist[${this.id}] .p-picklist-buttons .p-button {
margin-right: var(--inline-spacing);
margin-bottom: 0;
}
.p-picklist[${this.id}] .p-picklist-buttons .p-button:last-child {
margin-right: 0;
}
.p-picklist[${this.id}] .pi-angle-right:before {
content: "\\e930"
}
.p-picklist[${this.id}] .pi-angle-double-right:before {
content: "\\e92c"
}
.p-picklist[${this.id}] .pi-angle-left:before {
content: "\\e933"
}
.p-picklist[${this.id}] .pi-angle-double-left:before {
content: "\\e92f"
}
}
`;

this.styleElement.innerHTML = innerHTML;
}
}
Expand Down

0 comments on commit 7ab9c64

Please sign in to comment.