Old thread, but this was the top and best result I found when searching for this issue. I have a Material table that was doing the same thing.
Here is the fix I applied, just in case it helps someone else:
HTML
<th mat-header-cell *matHeaderCellDef mat-sort-header [class.pointer-events-none]="areWeResizingAColumn">
CSS (or SCSS)
.pointer-events-none {
pointer-events: none;
}
TS
areWeResizingAColumn: boolean = false;
onResizeColumn(event: any, index: number) {
this.areWeResizingAColumn = true;
this.checkResizing(event, index);
this.currentResizeIndex = index;
this.pressed = true;
this.startX = event.pageX;
this.startWidth = this.columnsToDisplay[index].width;
event.preventDefault();
this.mouseMove(index);
}
mouseMove(index: number) {
this.resizableMousemove = this.renderer.listen('document', 'mousemove', (event) => {
if (this.pressed && event.buttons ) {
const dx = (this.isResizingRight) ? (event.pageX - this.startX) : (-event.pageX + this.startX);
const width = this.startWidth + dx;
if ( this.currentResizeIndex === index && width > 50) {
this.setColumnWidthChanges(index, width);
}
} else {
this.areWeResizingAColumn = false;
event.preventDefault();
}
});
this.resizableMouseup = this.renderer.listen('document', 'mouseup', (event) => {
if (this.pressed) {
this.pressed = false;
this.currentResizeIndex = -1;
this.resizableMousemove();
this.resizableMouseup();
setTimeout(() => {this.areWeResizingAColumn = false;}, 100);
} else {
}
});
}
sortChange(sortParams: any) {
if (this.areWeResizingAColumn) return;
//Your other sort code here
}