Skip to content

Commit

Permalink
fix: ensure custom sort strategy still preseves sort if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdurow committed May 30, 2023
1 parent c991da0 commit da89534
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions code-component/PowerDragDrop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class PowerDragDrop implements ComponentFramework.StandardControl<IInputs
*/

this.currentItems = [];

const preserveSort = this.context.parameters.PreserveSort.raw === true;
// Get the items from each dropzone and work out the new custom sort position
Object.entries(this.zonesRegistered).forEach((sortable) => {
const children = sortable[1].sortable.el.children;
Expand Down Expand Up @@ -332,13 +332,15 @@ export class PowerDragDrop implements ComponentFramework.StandardControl<IInputs

// Add the updated items to the currentItems output dataset
reOrderableItems.forEach((item) => {
const position = preserveSort ? (item.OriginalPosition as number) : (item.Position as number);

this.currentItems.push({
DropZoneId: item.DropZoneId,
ItemId: item.ItemId,
Position: item.Position as number,
Position: position,
OriginalPosition: item.OriginalPosition as number,
OriginalDropZoneId: item.OriginalDropZoneId,
HasMovedPosition: item.HasMovedPosition === true,
HasMovedPosition: !preserveSort && item.HasMovedPosition === true,
HasMovedZone: item.HasMovedZone === true,
});
});
Expand Down

0 comments on commit da89534

Please sign in to comment.