Skip to content

Commit

Permalink
fix(common): Sort Service could throw on 3rd with undefined columnId (#…
Browse files Browse the repository at this point in the history
…1059)

- fixes issue found in Angular-Slickgrid ghiscoding/Angular-Slickgrid#1215
- when `multiColumnSort` is disabled, the 3rd clicks will not provide a sortCol object and was throwing an error for that reason, so use optional chaining to make sure it's defined before reading its sort column id
  • Loading branch information
ghiscoding authored Aug 1, 2023
1 parent 57a3a04 commit 1141230
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/common/src/services/sort.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class SortService {
handleLocalOnSort(_e: SlickEventData, args: SingleColumnSort | MultiColumnSort) {
// multiSort and singleSort are not exactly the same, but we want to structure it the same for the (for loop) after
// also to avoid having to rewrite the for loop in the sort, we will make the singleSort an array of 1 object
const sortColumns: Array<SingleColumnSort> = (args.multiColumnSort) ? (args as MultiColumnSort).sortCols : new Array({ columnId: (args as SingleColumnSort).sortCol.id, sortAsc: (args as SingleColumnSort).sortAsc, sortCol: (args as SingleColumnSort).sortCol });
const sortColumns: Array<SingleColumnSort> = (args.multiColumnSort) ? (args as MultiColumnSort).sortCols : new Array({ columnId: (args as SingleColumnSort).sortCol?.id ?? '', sortAsc: (args as SingleColumnSort).sortAsc, sortCol: (args as SingleColumnSort).sortCol });

// keep current sorters
this._currentLocalSorters = []; // reset current local sorters
Expand Down

0 comments on commit 1141230

Please sign in to comment.