@@ -38,6 +38,7 @@ import { IgxPaginatorToken } from 'igniteui-angular/paginator';
3838import { IgxGridCellMergePipe , IgxGridComponent , IgxGridFilteringPipe , IgxGridSortingPipe , IgxGridUnmergeActivePipe } from 'igniteui-angular/grids/grid' ;
3939
4040let NEXT_ID = 0 ;
41+ const HGRID_LIFECYCLE_PLACEHOLDER_TAG = 'igc-hgrid-lifecycle-placeholder' ;
4142
4243/**
4344 * @hidden @internal
@@ -662,6 +663,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
662663 * @hidden
663664 */
664665 public override ngOnInit ( ) {
666+ this . registerLifecyclePlaceholderElement ( ) ;
665667 // this.expansionStatesChange.pipe(takeUntil(this.destroy$)).subscribe((value: Map<any, boolean>) => {
666668 // const res = Array.from(value.entries()).filter(({1: v}) => v === true).map(([k]) => k);
667669 // });
@@ -674,6 +676,26 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
674676 super . ngOnInit ( ) ;
675677 }
676678
679+ // Event that triggers when element gets connected back to the DOM.
680+ // Used to determine when to reopen a previously closed row editing overlay.
681+ protected onLifecyclePlaceholderConnected ( ) : void {
682+ if ( this . rowEditable && this . crudService . rowInEditMode && this . rowEditingOverlay &&
683+ this . rowEditingOverlay . collapsed ) {
684+ // Row is in edit mode, but overlay is closed - reopen.
685+ this . openRowOverlay ( this . crudService . rowInEditMode . id ) ;
686+ }
687+
688+ }
689+
690+ // Event that triggers when element gets disconnected from the DOM, for example as a result of virtualization or caching.
691+ // Used to determine when to close the row editing overlay.
692+ protected onLifecyclePlaceholderDisconnected ( ) : void {
693+ if ( this . rowEditable && this . crudService . rowInEditMode && this . rowEditingOverlay ) {
694+ // disconnected from DOM (possibly cached) & row was in edit mode - close overlay.
695+ this . closeRowEditingOverlay ( ) ;
696+ }
697+ }
698+
677699 /**
678700 * @hidden
679701 */
@@ -720,6 +742,24 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
720742 this . parentIsland . showExpandAll : this . rootGrid . showExpandAll ;
721743 }
722744
745+ private registerLifecyclePlaceholderElement ( ) : void {
746+ if ( ! this . platform . isBrowser || typeof customElements === 'undefined' || customElements . get ( HGRID_LIFECYCLE_PLACEHOLDER_TAG ) ) {
747+ return ;
748+ }
749+
750+ class IgxHierarchicalGridLifecyclePlaceholderElement extends HTMLElement {
751+ public connectedCallback ( ) : void {
752+ this . dispatchEvent ( new CustomEvent ( 'igcConnected' , { bubbles : true , composed : true } ) ) ;
753+ }
754+
755+ public disconnectedCallback ( ) : void {
756+ this . dispatchEvent ( new CustomEvent ( 'igcDisconnected' , { bubbles : true , composed : true } ) ) ;
757+ }
758+ }
759+
760+ customElements . define ( HGRID_LIFECYCLE_PLACEHOLDER_TAG , IgxHierarchicalGridLifecyclePlaceholderElement ) ;
761+ }
762+
723763 /**
724764 * @hidden
725765 */
@@ -1232,15 +1272,15 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
12321272 {
12331273 name : null ,
12341274 fields : filterableFields . map ( f => ( {
1235- field : f . field ,
1236- dataType : f . dataType ,
1237- header : f . header ,
1238- editorOptions : f . editorOptions ,
1239- filters : f . filters ,
1240- pipeArgs : f . pipeArgs ,
1241- defaultTimeFormat : f . defaultTimeFormat ,
1242- defaultDateTimeFormat : f . defaultDateTimeFormat
1243- } ) ) as FieldType [ ]
1275+ field : f . field ,
1276+ dataType : f . dataType ,
1277+ header : f . header ,
1278+ editorOptions : f . editorOptions ,
1279+ filters : f . filters ,
1280+ pipeArgs : f . pipeArgs ,
1281+ defaultTimeFormat : f . defaultTimeFormat ,
1282+ defaultDateTimeFormat : f . defaultDateTimeFormat
1283+ } ) ) as FieldType [ ]
12441284 }
12451285 ] ;
12461286
@@ -1249,7 +1289,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
12491289 this . data [ 0 ] [ rowIsland . key ] [ 0 ] : null ;
12501290 return acc . concat ( this . generateChildEntity ( rowIsland , childFirstRowData ) ) ;
12511291 }
1252- , [ ] ) ;
1292+ , [ ] ) ;
12531293 }
12541294
12551295 return entities ;
0 commit comments