Skip to content

Commit

Permalink
Merge pull request #80 from mbektasbbg/unsubscribe_grid_wheel
Browse files Browse the repository at this point in the history
unsubscribe from grid wheel events on editor dispose
  • Loading branch information
Steven Silvester authored Jun 12, 2020
2 parents 9d7764b + 685659f commit 87ddf3c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/datagrid/src/celleditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ abstract class CellEditor implements ICellEditor, IDisposable {
return;
}

if (this._gridWheelEventHandler) {
this.cell.grid.node.removeEventListener('wheel', this._gridWheelEventHandler);
this._gridWheelEventHandler = null;
}

this._closeValidityNotification();

this._disposed = true;
Expand All @@ -392,10 +397,12 @@ abstract class CellEditor implements ICellEditor, IDisposable {

this.validator = (options && options.validator) ? options.validator : this.createValidatorBasedOnType();

cell.grid.node.addEventListener('wheel', () => {
this._gridWheelEventHandler = () => {
this._closeValidityNotification();
this.updatePosition();
});
};

cell.grid.node.addEventListener('wheel', this._gridWheelEventHandler);

this._addContainer();

Expand Down Expand Up @@ -722,6 +729,10 @@ abstract class CellEditor implements ICellEditor, IDisposable {
* Whether the value input is valid.
*/
private _validInput: boolean = true;
/**
* Grid wheel event handler.
*/
private _gridWheelEventHandler: ((this: HTMLElement, ev: WheelEvent) => any) | null = null;
}

/**
Expand Down

0 comments on commit 87ddf3c

Please sign in to comment.