Skip to content

Commit

Permalink
fix: regression with onSelectedRowsChanged not receiving correct `c…
Browse files Browse the repository at this point in the history
…aller` prop (#980)

- a regression was introduced when dropping jQuery, the SlickEvent structure changed in the `notify` function. Previously a SlickEvent would accept a CustomEvent directly and the previous code was expecting that event to exists and override its CustomEvent `detail`, however the newer approach is to always use a SlickEventData and no longer use the CustomEvent directly and this caused the regression since the SlickEventData doesn't have a `detail` property but rather something like this `SlickEventData { event: { detail } }`
  • Loading branch information
ghiscoding authored Jan 17, 2024
1 parent 5471666 commit ffbb335
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/plugins/slick.cellselectionmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export class SlickCellSelectionModel {

this._ranges = this.removeInvalidRanges(ranges);
if (rangeHasChanged) {
// provide extra "caller" argument through SlickEventData to avoid breaking pubsub event that only accepts an array of selected range
const eventData = new SlickEventData(null, this._ranges);
Object.defineProperty(eventData, 'detail', { writable: true, configurable: true, value: { caller: caller || 'SlickCellSelectionModel.setSelectedRanges' } });
// provide extra "caller" argument through SlickEventData event to avoid breaking the previous pubsub event structure
// that only accepts an array of selected range `SlickRange[]`, the SlickEventData args will be merged and used later by `onSelectedRowsChanged`
const eventData = new SlickEventData(new CustomEvent('click', { detail: { caller } }), this._ranges);
this.onSelectedRangesChanged.notify(this._ranges, eventData);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/slick.rowselectionmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export class SlickRowSelectionModel {
}
this._ranges = ranges;

// provide extra "caller" argument through SlickEventData to avoid breaking pubsub event that only accepts an array of selected range
const eventData = new SlickEventData(null, this._ranges);
Object.defineProperty(eventData, 'detail', { writable: true, configurable: true, value: { caller: caller || 'SlickRowSelectionModel.setSelectedRanges' } });
// provide extra "caller" argument through SlickEventData event to avoid breaking the previous pubsub event structure
// that only accepts an array of selected range `SlickRange[]`, the SlickEventData args will be merged and used later by `onSelectedRowsChanged`
const eventData = new SlickEventData(new CustomEvent('click', { detail: { caller } }), this._ranges);
this.onSelectedRangesChanged.notify(this._ranges, eventData);
}

Expand Down

0 comments on commit ffbb335

Please sign in to comment.