Skip to content

Commit

Permalink
fix(cdk-experimental/column-resize): Previous size was being sent for…
Browse files Browse the repository at this point in the history
… persistance rather than newly updated size in non-live resize mode. (#30161)
  • Loading branch information
kseamon authored Dec 11, 2024
1 parent ae3a993 commit 50d906b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cdk-experimental/column-resize/overlay-handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ export abstract class ResizeOverlayHandle implements AfterViewInit, OnDestroy {
this.updateResizeActive(false);

this.ngZone.run(() => {
const sizeMessage = {columnId: this.columnDef.name, size};
const sizeMessage = {
columnId: this.columnDef.name,
size: this._computeNewSize(size, this._cumulativeDeltaX),
};
if (completedSuccessfully) {
if (!this.resizeRef.liveUpdates) {
this._triggerResize(size, this._cumulativeDeltaX);
Expand Down
25 changes: 25 additions & 0 deletions src/material-experimental/column-resize/column-resize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,31 @@ describe('Material Popover Edit', () => {
expect(columnId).toBe('name');
(expect(sizePx) as any).isApproximately(initialColumnWidth + 5);
}));

it('persists the user-triggered size update (live updates off)', fakeAsync(() => {
const initialColumnWidth = component.getColumnWidth(1);

component.columnResize.liveResizeUpdates = false;

component.triggerHoverState();
fixture.detectChanges();

component.resizeColumnWithMouse(1, 5);
fixture.detectChanges();
flush();

component.completeResizeWithMouseInProgress(1);
flush();

component.endHoverState();
fixture.detectChanges();

expect(columnSizeStore.setSizeCalls.length).toBe(1);
const {tableId, columnId, sizePx} = columnSizeStore.setSizeCalls[0];
expect(tableId).toBe('theTable');
expect(columnId).toBe('name');
(expect(sizePx) as any).isApproximately(initialColumnWidth + 5);
}));
});
});

Expand Down

0 comments on commit 50d906b

Please sign in to comment.