@@ -96,6 +96,33 @@ export class CdkOverlayOrigin {
9696  constructor ( )  { } 
9797} 
9898
99+ /** Object used to configure the `CdkConnectedOverlay` directive. */ 
100+ export  interface  CdkConnectedOverlayConfig  { 
101+   origin ?: CdkOverlayOrigin  |  FlexibleConnectedPositionStrategyOrigin ; 
102+   positions ?: ConnectedPosition [ ] ; 
103+   positionStrategy ?: FlexibleConnectedPositionStrategy ; 
104+   offsetX ?: number ; 
105+   offsetY ?: number ; 
106+   width ?: number  |  string ; 
107+   height ?: number  |  string ; 
108+   minWidth ?: number  |  string ; 
109+   minHeight ?: number  |  string ; 
110+   backdropClass ?: string  |  string [ ] ; 
111+   panelClass ?: string  |  string [ ] ; 
112+   viewportMargin ?: ViewportMargin ; 
113+   scrollStrategy ?: ScrollStrategy ; 
114+   disableClose ?: boolean ; 
115+   transformOriginSelector ?: string ; 
116+   hasBackdrop ?: boolean ; 
117+   lockPosition ?: boolean ; 
118+   flexibleDimensions ?: boolean ; 
119+   growAfterOpen ?: boolean ; 
120+   push ?: boolean ; 
121+   disposeOnNavigation ?: boolean ; 
122+   usePopover ?: boolean ; 
123+   matchWidth ?: boolean ; 
124+ } 
125+ 
99126/** 
100127 * Directive to facilitate declarative creation of an 
101128 * Overlay using a FlexibleConnectedPositionStrategy. 
@@ -118,7 +145,6 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
118145  private  _offsetY : number ; 
119146  private  _position : FlexibleConnectedPositionStrategy ; 
120147  private  _scrollStrategyFactory  =  inject ( CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY ) ; 
121-   private  _disposeOnNavigation  =  false ; 
122148  private  _ngZone  =  inject ( NgZone ) ; 
123149
124150  /** Origin for the connected overlay. */ 
@@ -214,17 +240,20 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
214240
215241  /** Whether the overlay should be disposed of when the user goes backwards/forwards in history. */ 
216242  @Input ( { alias : 'cdkConnectedOverlayDisposeOnNavigation' ,  transform : booleanAttribute } ) 
217-   get  disposeOnNavigation ( ) : boolean  { 
218-     return  this . _disposeOnNavigation ; 
219-   } 
220-   set  disposeOnNavigation ( value : boolean )  { 
221-     this . _disposeOnNavigation  =  value ; 
222-   } 
243+   disposeOnNavigation : boolean  =  false ; 
223244
224245  /** Whether the connected overlay should be rendered inside a popover element or the overlay container. */ 
225246  @Input ( { alias : 'cdkConnectedOverlayUsePopover' ,  transform : booleanAttribute } ) 
226247  usePopover : boolean  =  false ; 
227248
249+   /** Shorthand for setting multiple overlay options at once. */ 
250+   @Input ( 'cdkConnectedOverlay' ) 
251+   set  _config ( value : string  |  CdkConnectedOverlayConfig )  { 
252+     if  ( typeof  value  !==  'string' )  { 
253+       this . _assignConfig ( value ) ; 
254+     } 
255+   } 
256+ 
228257  /** Event emitted when the backdrop is clicked. */ 
229258  @Output ( )  readonly  backdropClick  =  new  EventEmitter < MouseEvent > ( ) ; 
230259
@@ -419,19 +448,21 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
419448  attachOverlay ( )  { 
420449    if  ( ! this . _overlayRef )  { 
421450      this . _createOverlay ( ) ; 
422-     }  else  { 
423-       // Update the overlay size, in case the directive's inputs have changed 
424-       this . _overlayRef . getConfig ( ) . hasBackdrop  =  this . hasBackdrop ; 
425451    } 
426452
427-     if  ( ! this . _overlayRef ! . hasAttached ( ) )  { 
428-       this . _overlayRef ! . attach ( this . _templatePortal ) ; 
453+     const  ref  =  this . _overlayRef ! ; 
454+ 
455+     // Update the overlay size, in case the directive's inputs have changed 
456+     ref . getConfig ( ) . hasBackdrop  =  this . hasBackdrop ; 
457+ 
458+     if  ( ! ref . hasAttached ( ) )  { 
459+       ref . attach ( this . _templatePortal ) ; 
429460    } 
430461
431462    if  ( this . hasBackdrop )  { 
432-       this . _backdropSubscription  =  this . _overlayRef ! . backdropClick ( ) . subscribe ( event   =>   { 
433-         this . backdropClick . emit ( event ) ; 
434-       } ) ; 
463+       this . _backdropSubscription  =  ref 
464+         . backdropClick ( ) 
465+          . subscribe ( event   =>   this . backdropClick . emit ( event ) ) ; 
435466    }  else  { 
436467      this . _backdropSubscription . unsubscribe ( ) ; 
437468    } 
@@ -462,4 +493,29 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
462493    this . _positionSubscription . unsubscribe ( ) ; 
463494    this . open  =  false ; 
464495  } 
496+ 
497+   private  _assignConfig ( config : CdkConnectedOverlayConfig )  { 
498+     this . origin  =  config . origin  ??  this . origin ; 
499+     this . positions  =  config . positions  ??  this . positions ; 
500+     this . positionStrategy  =  config . positionStrategy  ??  this . positionStrategy ; 
501+     this . offsetX  =  config . offsetX  ??  this . offsetX ; 
502+     this . offsetY  =  config . offsetY  ??  this . offsetY ; 
503+     this . width  =  config . width  ??  this . width ; 
504+     this . height  =  config . height  ??  this . height ; 
505+     this . minWidth  =  config . minWidth  ??  this . minWidth ; 
506+     this . minHeight  =  config . minHeight  ??  this . minHeight ; 
507+     this . backdropClass  =  config . backdropClass  ??  this . backdropClass ; 
508+     this . panelClass  =  config . panelClass  ??  this . panelClass ; 
509+     this . viewportMargin  =  config . viewportMargin  ??  this . viewportMargin ; 
510+     this . scrollStrategy  =  config . scrollStrategy  ??  this . scrollStrategy ; 
511+     this . disableClose  =  config . disableClose  ??  this . disableClose ; 
512+     this . transformOriginSelector  =  config . transformOriginSelector  ??  this . transformOriginSelector ; 
513+     this . hasBackdrop  =  config . hasBackdrop  ??  this . hasBackdrop ; 
514+     this . lockPosition  =  config . lockPosition  ??  this . lockPosition ; 
515+     this . flexibleDimensions  =  config . flexibleDimensions  ??  this . flexibleDimensions ; 
516+     this . growAfterOpen  =  config . growAfterOpen  ??  this . growAfterOpen ; 
517+     this . push  =  config . push  ??  this . push ; 
518+     this . disposeOnNavigation  =  config . disposeOnNavigation  ??  this . disposeOnNavigation ; 
519+     this . usePopover  =  config . usePopover  ??  this . usePopover ; 
520+   } 
465521} 
0 commit comments