Skip to content

Commit c4eba02

Browse files
committed
perf(cdk-experimental/column-resize): add debounce to column header hover to prevent excessive handler rendering
This change adds a debounce to the headerCellHoveredDistinct observable to delay the rendering of handlers until the user hovers over the header for at least 300ms. This prevents unnecessary rendering of handlers during quick cursor movements.
1 parent ba5cf3d commit c4eba02

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)