Skip to content

Commit 12483ac

Browse files
authored
Merge branch '8.2.x' into set-width-hideallcolumns-82x
2 parents b20031b + 5b7bcba commit 12483ac

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

projects/igniteui-angular/src/lib/directives/template-outlet/template_outlet.directive.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export class IgxTemplateOutletDirective implements OnChanges {
3232
@Output()
3333
public onCachedViewLoaded = new EventEmitter<ICachedViewLoadedEventArgs>();
3434

35+
@Output()
36+
public onBeforeViewDetach = new EventEmitter<IViewChangeEventArgs>();
37+
3538
constructor(public _viewContainerRef: ViewContainerRef, private _zone: NgZone, public cdr: ChangeDetectorRef) {
3639
}
3740

@@ -65,6 +68,7 @@ export class IgxTemplateOutletDirective implements OnChanges {
6568
private _recreateView() {
6669
// detach old and create new
6770
if (this._viewRef) {
71+
this.onBeforeViewDetach.emit({ owner: this, view: this._viewRef, context: this.igxTemplateOutletContext });
6872
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this._viewRef));
6973
}
7074
if (this.igxTemplateOutlet) {
@@ -91,9 +95,11 @@ export class IgxTemplateOutletDirective implements OnChanges {
9195
if (view !== this._viewRef) {
9296
if (owner._viewContainerRef.indexOf(view) !== -1) {
9397
// detach in case view it is attached somewhere else at the moment.
98+
this.onBeforeViewDetach.emit({ owner: this, view: this._viewRef, context: this.igxTemplateOutletContext });
9499
owner._viewContainerRef.detach(owner._viewContainerRef.indexOf(view));
95100
}
96101
if (this._viewRef && this._viewContainerRef.indexOf(this._viewRef) !== -1) {
102+
this.onBeforeViewDetach.emit({ owner: this, view: this._viewRef, context: this.igxTemplateOutletContext });
97103
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this._viewRef));
98104
}
99105
this._viewRef = view;
@@ -111,6 +117,7 @@ export class IgxTemplateOutletDirective implements OnChanges {
111117
// if view exists, but template has been changed and there is a view in the cache with the related template
112118
// then detach old view and insert the stored one with the matching template
113119
// after that update its context.
120+
this.onBeforeViewDetach.emit({ owner: this, view: this._viewRef, context: this.igxTemplateOutletContext });
114121
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this._viewRef));
115122
this._viewRef = cachedView;
116123
const oldContext = this._cloneContext(cachedView.context);

projects/igniteui-angular/src/lib/grids/grid-base.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6045,6 +6045,20 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
60456045
return this.cellSelection !== GridSelectionMode.none;
60466046
}
60476047

6048+
/** @hidden */
6049+
public viewDetachHandler(args: ICachedViewLoadedEventArgs) {
6050+
const context = args.view.context;
6051+
if (context['templateID'] === 'dataRow') {
6052+
// some browsers (like FireFox and Edge) do not trigger onBlur when the focused element is detached from DOM
6053+
// hence we need to trigger it manually when cell is detached.
6054+
const row = this.getRowByIndex(context.index);
6055+
const focusedCell = row.cells.find(x => x.focused);
6056+
if (focusedCell) {
6057+
focusedCell.onBlur();
6058+
}
6059+
}
6060+
}
6061+
60486062
/**
60496063
* @hidden
60506064
*/

projects/igniteui-angular/src/lib/grids/grid/grid.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
<ng-template
132132
[igxTemplateOutlet]='isGroupByRecord(rowData) ? group_template : isSummaryRow(rowData) ? summary_template : record_template'
133133
[igxTemplateOutletContext]='getContext(rowData, rowIndex)'
134-
(onCachedViewLoaded)='cachedViewLoaded($event)'>
134+
(onCachedViewLoaded)='cachedViewLoaded($event)'
135+
(onBeforeViewDetach)='viewDetachHandler($event)' >
135136
</ng-template>
136137
</ng-template>
137138
<ng-container *ngTemplateOutlet="template"></ng-container>

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<ng-template
9494
[igxTemplateOutlet]='(isHierarchicalRecord(rowData) ? hierarchical_record_template : (isChildGridRecord(rowData) && isExpanded(rowData) ? child_record_template : hierarchical_record_template))'
9595
[igxTemplateOutletContext]='getContext(rowData)' (onViewCreated)='viewCreatedHandler($event)'
96-
(onViewMoved)='viewMovedHandler($event)' (onCachedViewLoaded)='cachedViewLoaded($event)'></ng-template>
96+
(onViewMoved)='viewMovedHandler($event)' (onCachedViewLoaded)='cachedViewLoaded($event)' (onBeforeViewDetach)='viewDetachHandler($event)'></ng-template>
9797
<!-- <ng-container *igxTemplateOutlet="(isHierarchicalRecord(rowData) ? hierarchical_record_template : (isChildGridRecord(rowData) && isExpanded(rowData) ? child_record_template : hierarchical_record_template)); context: getContext(rowData)"></ng-container> -->
9898
</ng-template>
9999
<ng-template #hierarchical_record_template let-rowIndex="index" let-rowData>

projects/igniteui-angular/src/lib/grids/row-drag.directive.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IRowDragEndEventArgs, IRowDragStartEventArgs } from './grid-base.compon
44
import { KEYS } from '../core/utils';
55
import { fromEvent, Subscription } from 'rxjs';
66
import { IgxRowComponent, IgxGridBaseComponent, IGridDataBindable } from './grid';
7+
import { IgxHierarchicalRowComponent } from './hierarchical-grid/hierarchical-row.component';
78

89

910
const ghostBackgroundClass = 'igx-grid__tr--ghost';
@@ -106,6 +107,15 @@ export class IgxRowDragDirective extends IgxDragDirective implements OnDestroy {
106107
};
107108
super.createGhost(pageX, pageY, this.row.nativeElement);
108109

110+
// check if there is an expander icon and create the ghost at the corresponding position
111+
if (this.isHierarchicalGrid) {
112+
const row = this.row as IgxHierarchicalRowComponent;
113+
if (row.expander) {
114+
const expanderWidth = row.expander.nativeElement.getBoundingClientRect().width;
115+
this._ghostHostX += expanderWidth;
116+
}
117+
}
118+
109119
const ghost = this.ghostElement;
110120

111121
const gridRect = this.row.grid.nativeElement.getBoundingClientRect();
@@ -144,6 +154,10 @@ export class IgxRowDragDirective extends IgxDragDirective implements OnDestroy {
144154
}
145155
this.endDragging();
146156
}
157+
158+
private get isHierarchicalGrid() {
159+
return this.row.grid.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid';
160+
}
147161
}
148162

149163
/**

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595

9696
<ng-template [igxTemplateOutlet]='isSummaryRow(rowData) ? summary_template : record_template'
9797
[igxTemplateOutletContext]='getContext(rowData, rowIndex)'
98-
(onCachedViewLoaded)='cachedViewLoaded($event)'>
98+
(onCachedViewLoaded)='cachedViewLoaded($event)'
99+
(onBeforeViewDetach)='viewDetachHandler($event)'>
99100
</ng-template>
100101
</ng-template>
101102
<ng-container *ngTemplateOutlet="template"></ng-container>

0 commit comments

Comments
 (0)