Skip to content
Open
35 changes: 23 additions & 12 deletions projects/igniteui-angular/grids/grid/src/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3717,10 +3717,10 @@ export abstract class IgxGridBaseDirective implements GridType,
filter(() => !this._init),
throttle(() =>
this.throttleTime$.pipe(
take(1),
switchMap(time => timer(time, this.throttleScheduler))
take(1),
switchMap(time => timer(time, this.throttleScheduler))
)
),
),
destructor
)
.subscribe((event) => {
Expand All @@ -3747,6 +3747,16 @@ export abstract class IgxGridBaseDirective implements GridType,
}
}
this.notifyChanges(true);
if (this.rowEditable && this.crudService.rowInEditMode && this.rowEditingOverlay &&
this.rowEditingOverlay.collapsed) {
// connected to DOM, row is in edit mode, but overlay is closed - reopen.
this.openRowOverlay(this.crudService.rowInEditMode.id);
}
}

if (!this.nativeElement.isConnected && this.rowEditable && this.crudService.rowInEditMode && this.rowEditingOverlay) {
// disconnected from DOM (possibly cached) & row was in edit mode - close overlay.
this.closeRowEditingOverlay();
}
});
});
Expand All @@ -3766,22 +3776,23 @@ export abstract class IgxGridBaseDirective implements GridType,
this.overlayService.opened.pipe(destructor).subscribe((event) => {
const overlaySettings = this.overlayService.getOverlayById(event.id)?.settings;

Comment thread
MayaKirova marked this conversation as resolved.
// do not hide the advanced filtering overlay on scroll
if (this._advancedFilteringOverlayId === event.id) {
// this sets focus to query builder button for some reason...
if (this._advancedFilteringOverlayId === event.id) {
const instance = event.componentRef.instance as IgxAdvancedFilteringDialogComponent;
if (instance) {
instance.lastActiveNode = this.navigation.activeNode;
instance.queryBuilder.setAddButtonFocus();
}
return;
Comment thread
damyanpetev marked this conversation as resolved.
}

// do not hide the overlay if it's attached to a row
if (this.rowEditingOverlay?.overlayId === event.id) {
const inRow = (overlaySettings?.target as HTMLElement)?.classList.contains("igx-grid__tr");
// do not hide the overlay if it's attached to a row on scroll
if (inRow) {
return;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These rows should really not need additional changes, just the outlet check below;
Also the row edit already had hide/show handling, so the additional scrollNotify logic is also sus

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to match the existing behavior. The row edit overlay did not close on scroll in previous versions. There is just handling to reposition it.


if (overlaySettings?.outlet === this.outlet && this.overlayIDs.indexOf(event.id) === -1) {
// check whole grid, since some overlays like the advanced filtering, are outside the body.
const isInGrid = this.nativeElement.contains(overlaySettings?.target as Node);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check overlaySettings?.target is Node instead of cast, as contains can throw

if (isInGrid && this.overlayIDs.indexOf(event.id) === -1) {
Comment thread
MayaKirova marked this conversation as resolved.
Outdated
Comment thread
MayaKirova marked this conversation as resolved.
this.overlayIDs.push(event.id);
}
Comment thread
MayaKirova marked this conversation as resolved.
Outdated
});
Expand Down Expand Up @@ -4047,8 +4058,8 @@ export abstract class IgxGridBaseDirective implements GridType,
const activeRow = this.navigation.activeNode?.row;

const selectedCellIndexes = this.selectionService.selection
? Array.from(this.selectionService.selection.keys())
: [];
? Array.from(this.selectionService.selection.keys())
: [];
this._activeRowIndexes = [activeRow, ...selectedCellIndexes];
return this._activeRowIndexes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
expect(GridFunctions.getAdvancedFilteringComponent(fix)).toBeNull();
}));

it('Should close Advanced Filtering dialog on vertical scroll.', fakeAsync(() => {
grid.openAdvancedFilteringDialog();
fix.detectChanges();
tick(100);
fix.detectChanges();

expect(GridFunctions.getAdvancedFilteringComponent(fix)).not.toBeNull();

(grid as any).verticalScrollHandler({ target: grid.verticalScrollContainer.getScroll() });
tick(200);
fix.detectChanges();

expect(GridFunctions.getAdvancedFilteringComponent(fix)).toBeNull();
}));

it('Should close Advanced Filtering dialog through API by respecting \'applyChanges\' argument.', fakeAsync(() => {
grid.openAdvancedFilteringDialog();
fix.detectChanges();
Expand Down
15 changes: 15 additions & 0 deletions projects/igniteui-angular/grids/grid/src/grid-row-editing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,21 @@ describe('IgxGrid - Row Editing #grid', () => {
cell.editMode = false;
});

it('Overlay position: Should keep row editing overlay open on vertical scroll', fakeAsync(() => {
cell = grid.getCellByColumn(0, 'ProductName');
cell.editMode = true;
fix.detectChanges();

expect(grid.rowEditingOverlay.collapsed).toBeFalse();

(grid as any).verticalScrollHandler({ target: grid.verticalScrollContainer.getScroll() });
tick();
fix.detectChanges();

expect(GridFunctions.getRowEditingOverlay(fix)).toBeTruthy();
expect(grid.rowEditingOverlay.collapsed).toBeFalse();
}));

it('should end row editing when clearing or applying advanced filter', () => {
fix.detectChanges();
const row = grid.gridAPI.get_row_by_index(2);
Expand Down
18 changes: 11 additions & 7 deletions src/app/hierarchical-grid/hierarchical-grid.sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h4 class="sample-title">Sample One</h4>
<button igxButton="contained" (click)="getState()">Get state</button>
<igx-hierarchical-grid [batchEditing]="true" #grid1 [data]="localData" [showExpandAll]="true" [pinning]="{rows: 0}" class="hgrid"
[rowSelection]="selectionMode" [autoGenerate]="false" [allowFiltering]="true"
[rowDraggable]="true" [height]="'800px'" filterMode="excelStyleFilter" [width]="'100%'" [expandChildren]="rootExpanded"
[rowDraggable]="true" [height]="'500px'" filterMode="excelStyleFilter" [width]="'100%'" [expandChildren]="rootExpanded"
#hGrid [rowClasses]="rowClasses">
<igx-grid-excel-style-filtering [minHeight]="'200px'" [maxHeight]="'500px'">
<igx-excel-style-column-operations>
Expand Down Expand Up @@ -53,9 +53,9 @@ <h4 class="sample-title">Sample One</h4>
<ng-template igxRowCollapsedIndicator>
<igx-icon role="button" family="default" name="add"></igx-icon>
</ng-template>
<igx-row-island [rowDraggable]="true" [height]="'400px'" [showExpandAll]="true" [key]="'childData'"
[autoGenerate]="false" [allowFiltering]='true' [rowSelection]='selectionMode' [rowEditable]="true"
[expandChildren]="firstLevelExpanded" #layout1 [allowFiltering]="true" filterMode="excelStyleFilter">
<igx-row-island [primaryKey]="'ID'" [rowEditable]="true" [allowAdvancedFiltering]="true" [rowDraggable]="true" [height]="'400px'" [showExpandAll]="true" [key]="'childData'"
[autoGenerate]="false" [allowFiltering]="true" [rowSelection]="selectionMode"
[expandChildren]="firstLevelExpanded" #layout1 filterMode="excelStyleFilter">
<igx-grid-excel-style-filtering [minHeight]="'200px'" [maxHeight]="'360px'">
<igx-excel-style-column-operations>
<igx-excel-style-header [showPinning]="false" [showHiding]="true">
Expand All @@ -66,10 +66,14 @@ <h4 class="sample-title">Sample One</h4>
<igx-excel-style-search></igx-excel-style-search>
</igx-excel-style-filter-operations>
</igx-grid-excel-style-filtering>

<igx-action-strip>
<igx-grid-editing-actions [addRow]="true"></igx-grid-editing-actions>
<igx-grid-pinning-actions></igx-grid-pinning-actions>
</igx-action-strip>
<igx-grid-toolbar *igxGridToolbar>
<igx-grid-toolbar-title>{{ toolbarTitle }}</igx-grid-toolbar-title>
<igx-grid-toolbar-actions>
<igx-grid-toolbar-advanced-filtering></igx-grid-toolbar-advanced-filtering>
<igx-grid-toolbar-pinning></igx-grid-toolbar-pinning>
<igx-grid-toolbar-hiding></igx-grid-toolbar-hiding>
<igx-grid-toolbar-exporter></igx-grid-toolbar-exporter>
Expand All @@ -79,8 +83,8 @@ <h4 class="sample-title">Sample One</h4>
</igx-paginator>
<igx-column field="ID" [hasSummary]="false" [dataType]="'number'"></igx-column>
<igx-column-group header="Information2">
<igx-column field="ChildLevels" [resizable]="true" [groupable]="true"></igx-column>
<igx-column field="ProductName" [resizable]="true" [groupable]="true"></igx-column>
<igx-column field="ChildLevels" [resizable]="true" [groupable]="true" ></igx-column>
<igx-column field="ProductName" [resizable]="true" [groupable]="true" [editable]="true"></igx-column>
</igx-column-group>
<ng-template let-data igxRowDragGhost>
<div class="dragGhost">
Expand Down
3 changes: 2 additions & 1 deletion src/app/hierarchical-grid/hierarchical-grid.sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, ViewChild, ChangeDetectorRef, AfterViewInit, HostBinding } f
import { GridSearchBoxComponent } from '../grid-search-box/grid-search-box.component';
import {
IgxRowIslandComponent,
IgxActionStripComponent,
IgxHierarchicalGridComponent,
IGridCellEventArgs,
GridSelectionMode,
Expand All @@ -16,7 +17,7 @@ import {
selector: 'app-hierarchical-grid-sample',
styleUrls: ['hierarchical-grid.sample.scss'],
templateUrl: 'hierarchical-grid.sample.html',
imports: [GridSearchBoxComponent, IGX_HIERARCHICAL_GRID_DIRECTIVES, IgxIconComponent, IGX_BUTTON_GROUP_DIRECTIVES]
imports: [GridSearchBoxComponent, IGX_HIERARCHICAL_GRID_DIRECTIVES, IgxIconComponent, IGX_BUTTON_GROUP_DIRECTIVES, IgxActionStripComponent]
})
export class HierarchicalGridSampleComponent implements AfterViewInit {
@HostBinding('style.--ig-size')
Expand Down
Loading