components icon indicating copy to clipboard operation
components copied to clipboard

fix(material/select): run viewportRuler change event outside the zone

Open llorenspujol opened this issue 6 years ago • 3 comments

MatSelect component was listening viewportRuler change event inside the zone. Due to this, a CD cycle was fired after every 'resize' event, event there was nothing to detect changes. It only make sense to run a CD cycle if the mat-select panel is open.

Fixes #18546

llorenspujol avatar Feb 19 '20 11:02 llorenspujol

I think this should resolve it for all components, not just mat-select: https://github.com/angular/components/pull/15814.

crisbeto avatar Feb 19 '20 12:02 crisbeto

It makes sense (I didn't see this issue.).

About this MR #15814 where is handled globally, I miss a re-zone entering in case the mat-select has the panel open.

I mean this particular code (from my MR):

if (this._panelOpen) {
    this._ngZone.run(() => {
         this._triggerRect = this.trigger.nativeElement.getBoundingClientRect();
         this._changeDetectorRef.markForCheck();
    })
}

llorenspujol avatar Feb 19 '20 12:02 llorenspujol

Sure, that makes sense, but the outer one should still be removed.

crisbeto avatar Feb 19 '20 16:02 crisbeto