Skip to content

Commit edc750b

Browse files
committed
perf(cdk-experimental/column-resize): add debounce to column header hover to prevent excessive handler rendering
Improve performance for the `_updateOverlayHandleHeight()` method in the `cdk-experimental` column resize feature. Currently, the method immediately updates the overlay handle height when hovering over a resizable column header. By wrapping the `updateSize` call inside a `requestAnimationFrame()`, the height update is deferred to the next repaint, improving responsiveness during hover interactions.
1 parent ba5cf3d commit edc750b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cdk-experimental/column-resize/event-dispatcher.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {Injectable, NgZone, inject} from '@angular/core';
1010
import {combineLatest, MonoTypeOperatorFunction, Observable, Subject} from 'rxjs';
11-
import {distinctUntilChanged, map, share, skip, startWith} from 'rxjs/operators';
11+
import {distinctUntilChanged, map, share, skip, startWith, debounceTime} from 'rxjs/operators';
1212

1313
import {_closest} from '../popover-edit';
1414

@@ -33,7 +33,7 @@ export class HeaderRowEventDispatcher {
3333
readonly overlayHandleActiveForCell = new Subject<Element | null>();
3434

3535
/** Distinct and shared version of headerCellHovered. */
36-
readonly headerCellHoveredDistinct = this.headerCellHovered.pipe(distinctUntilChanged(), share());
36+
readonly headerCellHoveredDistinct = this.headerCellHovered.pipe(distinctUntilChanged(), debounceTime(300), share());
3737

3838
/**
3939
* Emits the header that is currently hovered or hosting an active resize event (with active

0 commit comments

Comments
 (0)