Skip to content

Commit 50d906b

Browse files
authoredDec 11, 2024··
fix(cdk-experimental/column-resize): Previous size was being sent for persistance rather than newly updated size in non-live resize mode. (#30161)
1 parent ae3a993 commit 50d906b

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
 

‎src/cdk-experimental/column-resize/overlay-handle.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ export abstract class ResizeOverlayHandle implements AfterViewInit, OnDestroy {
218218
this.updateResizeActive(false);
219219

220220
this.ngZone.run(() => {
221-
const sizeMessage = {columnId: this.columnDef.name, size};
221+
const sizeMessage = {
222+
columnId: this.columnDef.name,
223+
size: this._computeNewSize(size, this._cumulativeDeltaX),
224+
};
222225
if (completedSuccessfully) {
223226
if (!this.resizeRef.liveUpdates) {
224227
this._triggerResize(size, this._cumulativeDeltaX);

‎src/material-experimental/column-resize/column-resize.spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,31 @@ describe('Material Popover Edit', () => {
691691
expect(columnId).toBe('name');
692692
(expect(sizePx) as any).isApproximately(initialColumnWidth + 5);
693693
}));
694+
695+
it('persists the user-triggered size update (live updates off)', fakeAsync(() => {
696+
const initialColumnWidth = component.getColumnWidth(1);
697+
698+
component.columnResize.liveResizeUpdates = false;
699+
700+
component.triggerHoverState();
701+
fixture.detectChanges();
702+
703+
component.resizeColumnWithMouse(1, 5);
704+
fixture.detectChanges();
705+
flush();
706+
707+
component.completeResizeWithMouseInProgress(1);
708+
flush();
709+
710+
component.endHoverState();
711+
fixture.detectChanges();
712+
713+
expect(columnSizeStore.setSizeCalls.length).toBe(1);
714+
const {tableId, columnId, sizePx} = columnSizeStore.setSizeCalls[0];
715+
expect(tableId).toBe('theTable');
716+
expect(columnId).toBe('name');
717+
(expect(sizePx) as any).isApproximately(initialColumnWidth + 5);
718+
}));
694719
});
695720
});
696721

0 commit comments

Comments
 (0)
Please sign in to comment.