@@ -182,28 +182,28 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
182182
183183 private _listenForRowHoverEvents ( ) : void {
184184 const element = this . elementRef . nativeElement ! ;
185- const takeUntilDestroyed = takeUntil < boolean > ( this . destroyed ) ;
186185
187186 this . eventDispatcher
188187 . resizeOverlayVisibleForHeaderRow ( _closest ( element , HEADER_ROW_SELECTOR ) ! )
189- . pipe ( takeUntilDestroyed )
188+ . pipe ( takeUntil ( this . destroyed ) )
190189 . subscribe ( hoveringRow => {
190+ if ( this . _isDestroyed ) {
191+ return ;
192+ }
193+
191194 if ( hoveringRow ) {
192195 const tooBigToResize =
193196 this . maxWidthPxInternal < Number . MAX_SAFE_INTEGER &&
194197 element . offsetWidth > this . maxWidthPxInternal ;
195198 element . classList . toggle ( RESIZE_DISABLED_CLASS , tooBigToResize ) ;
196199
197200 if ( ! tooBigToResize ) {
198- if ( ! this . overlayRef ) {
199- this . overlayRef = this . _createOverlayForHandle ( ) ;
200- }
201-
201+ this . overlayRef ??= this . _createOverlayForHandle ( ) ;
202202 this . _showHandleOverlay ( ) ;
203203 }
204- } else if ( this . overlayRef ) {
204+ } else {
205205 // todo - can't detach during an active resize - need to work that out
206- this . overlayRef . detach ( ) ;
206+ this . overlayRef ? .detach ( ) ;
207207 }
208208 } ) ;
209209 }
@@ -258,7 +258,7 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
258258 private _cleanUpAfterResize ( columnSize : ColumnSizeAction ) : void {
259259 this . elementRef . nativeElement ! . classList . remove ( OVERLAY_ACTIVE_CLASS ) ;
260260
261- if ( this . overlayRef && this . overlayRef . hasAttached ( ) ) {
261+ if ( this . overlayRef ? .hasAttached ( ) ) {
262262 this . _updateOverlayHandleHeight ( ) ;
263263 this . overlayRef . updatePosition ( ) ;
264264
@@ -293,18 +293,20 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
293293 }
294294
295295 private _showHandleOverlay ( ) : void {
296- this . _updateOverlayHandleHeight ( ) ;
297- this . overlayRef ! . attach ( this . _createHandlePortal ( ) ) ;
296+ if ( ! this . _isDestroyed ) {
297+ this . _updateOverlayHandleHeight ( ) ;
298+ this . overlayRef ?. attach ( this . _createHandlePortal ( ) ) ;
298299
299- // Needed to ensure that all of the lifecycle hooks inside the overlay run immediately.
300- this . changeDetectorRef . markForCheck ( ) ;
300+ // Needed to ensure that all of the lifecycle hooks inside the overlay run immediately.
301+ this . changeDetectorRef . markForCheck ( ) ;
302+ }
301303 }
302304
303305 private _updateOverlayHandleHeight ( ) {
304306 runInInjectionContext ( this . injector , ( ) => {
305307 afterNextRender ( {
306308 write : ( ) => {
307- this . overlayRef ! . updateSize ( { height : this . elementRef . nativeElement ! . offsetHeight } ) ;
309+ this . overlayRef ? .updateSize ( { height : this . elementRef . nativeElement ! . offsetHeight } ) ;
308310 } ,
309311 } ) ;
310312 } ) ;
0 commit comments