@@ -13,7 +13,6 @@ import {
1313 Directive ,
1414 ElementRef ,
1515 EmbeddedViewRef ,
16- Input ,
1716 NgZone ,
1817 OnDestroy ,
1918 TemplateRef ,
@@ -110,34 +109,42 @@ export class CdkEditable implements AfterViewInit, OnDestroy {
110109 }
111110}
112111
112+ const POPOVER_EDIT_HOST_BINDINGS = {
113+ 'tabIndex' : '0' ,
114+ 'class' : 'cdk-popover-edit-cell' ,
115+ '[attr.aria-haspopup]' : 'true' ,
116+ } ;
117+
118+ const POPOVER_EDIT_INPUTS = [
119+ 'template: cdkPopoverEdit' ,
120+ 'context: cdkPopoverEditContext' ,
121+ 'colspan: cdkPopoverEditColspan' ,
122+ ] ;
123+
113124/**
114125 * Attaches an ng-template to a cell and shows it when instructed to by the
115126 * EditEventDispatcher service.
116127 * Makes the cell focusable.
117128 */
118129@Directive ( {
119130 selector : '[cdkPopoverEdit]:not([cdkPopoverEditTabOut])' ,
120- host : {
121- 'tabIndex' : '0' ,
122- 'class' : 'cdk-popover-edit-cell' ,
123- '[attr.aria-haspopup]' : 'true' ,
124- }
131+ host : POPOVER_EDIT_HOST_BINDINGS ,
132+ inputs : POPOVER_EDIT_INPUTS ,
125133} )
126134export class CdkPopoverEdit < C > implements AfterViewInit , OnDestroy {
127135 /** The edit lens template shown over the cell on edit. */
128- @ Input ( 'cdkPopoverEdit' ) template : TemplateRef < any > | null = null ;
136+ template : TemplateRef < any > | null = null ;
129137
130138 /**
131139 * Implicit context to pass along to the template. Can be omitted if the template
132140 * is defined within the cell.
133141 */
134- @ Input ( 'cdkPopoverEditContext' ) context ?: C ;
142+ context ?: C ;
135143
136144 /**
137145 * Specifies that the popup should cover additional table cells before and/or after
138146 * this one.
139147 */
140- @Input ( 'cdkPopoverEditColspan' )
141148 get colspan ( ) : CdkPopoverEditColspan {
142149 return this . _colspan ;
143150 }
@@ -184,6 +191,10 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
184191 this . services . editEventDispatcher . doneEditingCell ( this . elementRef . nativeElement ! ) ;
185192 }
186193
194+ protected panelClass ( ) : string {
195+ return EDIT_PANE_CLASS ;
196+ }
197+
187198 private _startListeningToEditEvents ( ) : void {
188199 this . services . editEventDispatcher . editingCell ( this . elementRef . nativeElement ! )
189200 . pipe ( takeUntil ( this . destroyed ) )
@@ -207,7 +218,7 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
207218 private _createEditOverlay ( ) : void {
208219 this . overlayRef = this . services . overlay . create ( {
209220 disposeOnNavigation : true ,
210- panelClass : EDIT_PANE_CLASS ,
221+ panelClass : this . panelClass ( ) ,
211222 positionStrategy : this . _getPositionStrategy ( ) ,
212223 scrollStrategy : this . services . overlay . scrollStrategies . reposition ( ) ,
213224 } ) ;
@@ -276,12 +287,9 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
276287 * Makes the cell focusable.
277288 */
278289@Directive ( {
279- selector : '[cdkPopoverEdit] [cdkPopoverEditTabOut]' ,
280- host : {
281- 'tabIndex' : '0' ,
282- 'class' : 'cdk-popover-edit-cell' ,
283- '[attr.aria-haspopup]' : 'true' ,
284- }
290+ selector : '[cdkPopoverEdit][cdkPopoverEditTabOut]' ,
291+ host : POPOVER_EDIT_HOST_BINDINGS ,
292+ inputs : POPOVER_EDIT_INPUTS ,
285293} )
286294export class CdkPopoverEditTabOut < C > extends CdkPopoverEdit < C > {
287295 protected focusTrap ?: FocusEscapeNotifier ;
@@ -324,9 +332,6 @@ export class CdkPopoverEditTabOut<C> extends CdkPopoverEdit<C> {
324332 */
325333@Directive ( {
326334 selector : '[cdkRowHoverContent]' ,
327- host : {
328- '[attr.aria-hidden]' : 'true' ,
329- }
330335} )
331336export class CdkRowHoverContent implements AfterViewInit , OnDestroy {
332337 protected readonly destroyed = new ReplaySubject < void > ( ) ;
@@ -350,6 +355,14 @@ export class CdkRowHoverContent implements AfterViewInit, OnDestroy {
350355 }
351356 }
352357
358+ protected initElement ( element : HTMLElement ) : void ;
359+ protected initElement ( ) : void {
360+ }
361+
362+ protected prepareElement ( element : HTMLElement ) : void ;
363+ protected prepareElement ( ) : void {
364+ }
365+
353366 private _listenForHoverEvents ( ) : void {
354367 this . services . editEventDispatcher . hoveringOnRow ( this . elementRef . nativeElement ! )
355368 . pipe ( takeUntil ( this . destroyed ) )
@@ -360,9 +373,11 @@ export class CdkRowHoverContent implements AfterViewInit, OnDestroy {
360373 // Not doing any positioning in CDK version. Material version
361374 // will absolutely position on right edge of cell.
362375 this . viewRef = this . viewContainerRef . createEmbeddedView ( this . templateRef , { } ) ;
376+ this . initElement ( this . elementRef . nativeElement ! . nextSibling as HTMLElement ) ;
363377 } else {
364378 this . viewContainerRef . insert ( this . viewRef ) ;
365379 }
380+ this . prepareElement ( this . elementRef . nativeElement ! . nextSibling as HTMLElement ) ;
366381 } else if ( this . viewRef ) {
367382 this . viewContainerRef . detach ( this . viewContainerRef . indexOf ( this . viewRef ) ) ;
368383 }
0 commit comments