Skip to content

Commit 444e0da

Browse files
authored
fix(grid-pinning): remove hide call in scrollToRow - master (#16784)
1 parent 58e6489 commit 444e0da

4 files changed

Lines changed: 55 additions & 5 deletions

File tree

projects/igniteui-angular/core/src/grid-column-actions/token.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export abstract class IgxActionStripToken {
77
public abstract cdr: ChangeDetectorRef
88
public abstract context: any;
99
public abstract menuOverlaySettings: OverlaySettings;
10+
public abstract actionButtons: QueryList<IgxActionStripActionsToken>;
1011
public abstract get hideOnRowLeave(): boolean;
1112

1213
public abstract show(context?: any): void;

projects/igniteui-angular/grids/core/src/grid-actions/grid-pinning-actions.component.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,26 @@ describe('igxGridPinningActions #grid ', () => {
7171
const secondToLastVisible = grid.rowList.toArray()[grid.rowList.length - 2];
7272
expect(secondToLastVisible.key).toEqual('FAMIA');
7373
});
74+
75+
it('should not hide action strip in base mode when scrollToRow is invoked', () => {
76+
grid.pinRow('FAMIA');
77+
fixture.detectChanges();
78+
79+
const pinnedRow = grid.pinnedRows[0];
80+
actionStrip.show(pinnedRow);
81+
fixture.detectChanges();
82+
83+
const pinningActions = fixture.debugElement.query(By.directive(IgxGridPinningActionsComponent))
84+
.componentInstance as IgxGridPinningActionsComponent;
85+
spyOn<any>(grid, 'scrollTo');
86+
87+
pinningActions.scrollToRow(null);
88+
fixture.detectChanges();
89+
90+
expect((grid as any).scrollTo).toHaveBeenCalledWith(pinnedRow.data, 0);
91+
expect(actionStrip.hidden).toBeFalse();
92+
expect(actionStrip.context).toBe(pinnedRow);
93+
});
7494
});
7595

7696
describe('Menu ', () => {

projects/igniteui-angular/grids/core/src/grid-actions/grid-pinning-actions.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ export class IgxGridPinningActionsComponent extends IgxGridActionsBaseDirective
126126
const context = this.strip.context;
127127
const grid = context.grid;
128128
grid.scrollTo(context.data, 0);
129-
this.strip.hide();
129+
130+
if (this.asMenuItems) {
131+
this.strip.hide();
132+
}
130133
}
131134

132135
private registerSVGIcons(): void {

projects/igniteui-angular/grids/grid/src/grid-base.directive.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ import { IgxGridRowComponent } from './grid-row.component';
108108
import { IgxGridGroupByAreaComponent } from './grouping/grid-group-by-area.component';
109109
import { IgxPaginatorToken, type IgxPaginatorComponent } from 'igniteui-angular/paginator';
110110
import { IgxSnackbarComponent } from 'igniteui-angular/snackbar';
111-
import { CharSeparatedValueData, DropPosition, FilterMode, getUUID, GridCellMergeMode, GridKeydownTargetType, GridPagingMode, GridSelectionMode, GridSelectionRange, GridServiceType, GridSummaryPosition, GridType, GridValidationTrigger, IActiveNode, IActiveNodeChangeEventArgs, ICellPosition, IClipboardOptions, IColumnMovingEndEventArgs, IColumnMovingEventArgs, IColumnMovingStartEventArgs, IColumnResizeEventArgs, IColumnsAutoGeneratedEventArgs, IColumnSelectionEventArgs, IColumnVisibilityChangedEventArgs, IColumnVisibilityChangingEventArgs, IFilteringEventArgs, IGridCellEventArgs, IGridClipboardEvent, IGridContextMenuEventArgs, IGridEditDoneEventArgs, IGridEditEventArgs, IGridFormGroupCreatedEventArgs, IGridKeydownEventArgs, IGridRowEventArgs, IGridScrollEventArgs, IGridToolbarExportEventArgs, IGridValidationStatusEventArgs, IGX_GRID_SERVICE_BASE, IgxAdvancedFilteringDialogComponent, IgxCell, IgxColumnComponent, IgxColumnGroupComponent, IgxColumnResizingService, IgxDragIndicatorIconDirective, IgxEditRow, IgxExcelStyleHeaderIconDirective, IgxExcelStyleLoadingValuesTemplateDirective, IgxFilteringService, IgxGridBodyDirective, IgxGridCellComponent, IgxGridColumnResizerComponent, IgxGridEmptyTemplateContext, IgxGridEmptyTemplateDirective, IgxGridExcelStyleFilteringComponent, IgxGridFilteringCellComponent, IgxGridFilteringRowComponent, IgxGridHeaderComponent, IgxGridHeaderGroupComponent, IgxGridHeaderRowComponent, IgxGridHeaderTemplateContext, IgxGridLoadingTemplateDirective, IgxGridNavigationService, IgxGridRowDragGhostContext, IgxGridRowEditActionsTemplateContext, IgxGridRowEditTemplateContext, IgxGridRowEditTextTemplateContext, IgxGridRowTemplateContext, IgxGridSelectionService, IgxGridSummaryService, IgxGridTemplateContext, IgxGridToolbarComponent, IgxGridTransaction, IgxGridValidationService, IgxHeaderCollapsedIndicatorDirective, IgxHeaderExpandedIndicatorDirective, IgxHeadSelectorDirective, IgxHeadSelectorTemplateContext, IgxRowAddTextDirective, IgxRowCollapsedIndicatorDirective, IgxRowDirective, IgxRowDragGhostDirective, IgxRowEditActionsDirective, IgxRowEditTabStopDirective, IgxRowEditTemplateDirective, IgxRowEditTextDirective, IgxRowExpandedIndicatorDirective, IgxRowSelectorDirective, IgxRowSelectorTemplateContext, IgxSortAscendingHeaderIconDirective, IgxSortDescendingHeaderIconDirective, IgxSortHeaderIconDirective, IgxSummaryRowComponent, IgxToolbarToken, IPinColumnCancellableEventArgs, IPinColumnEventArgs, IPinningConfig, IPinRowEventArgs, IRowDataCancelableEventArgs, IRowDataEventArgs, IRowDragEndEventArgs, IRowDragStartEventArgs, IRowSelectionEventArgs, IRowToggleEventArgs, ISearchInfo, ISizeInfo, ISortingEventArgs, RowEditPositionStrategy, RowPinningPosition, RowType, WatchChanges } from 'igniteui-angular/grids/core';
111+
import { CharSeparatedValueData, DropPosition, FilterMode, getUUID, GridCellMergeMode, GridKeydownTargetType, GridPagingMode, GridSelectionMode, GridSelectionRange, GridServiceType, GridSummaryPosition, GridType, GridValidationTrigger, IActiveNode, IActiveNodeChangeEventArgs, ICellPosition, IClipboardOptions, IColumnMovingEndEventArgs, IColumnMovingEventArgs, IColumnMovingStartEventArgs, IColumnResizeEventArgs, IColumnsAutoGeneratedEventArgs, IColumnSelectionEventArgs, IColumnVisibilityChangedEventArgs, IColumnVisibilityChangingEventArgs, IFilteringEventArgs, IGridCellEventArgs, IGridClipboardEvent, IGridContextMenuEventArgs, IGridEditDoneEventArgs, IGridEditEventArgs, IGridFormGroupCreatedEventArgs, IGridKeydownEventArgs, IGridRowEventArgs, IGridScrollEventArgs, IGridToolbarExportEventArgs, IGridValidationStatusEventArgs, IGX_GRID_SERVICE_BASE, IgxAdvancedFilteringDialogComponent, IgxCell, IgxColumnComponent, IgxColumnGroupComponent, IgxColumnResizingService, IgxDragIndicatorIconDirective, IgxEditRow, IgxExcelStyleHeaderIconDirective, IgxExcelStyleLoadingValuesTemplateDirective, IgxFilteringService, IgxGridBodyDirective, IgxGridCellComponent, IgxGridColumnResizerComponent, IgxGridEmptyTemplateContext, IgxGridEmptyTemplateDirective, IgxGridExcelStyleFilteringComponent, IgxGridFilteringCellComponent, IgxGridFilteringRowComponent, IgxGridHeaderComponent, IgxGridHeaderGroupComponent, IgxGridHeaderRowComponent, IgxGridHeaderTemplateContext, IgxGridLoadingTemplateDirective, IgxGridNavigationService, IgxGridPinningActionsComponent, IgxGridRowDragGhostContext, IgxGridRowEditActionsTemplateContext, IgxGridRowEditTemplateContext, IgxGridRowEditTextTemplateContext, IgxGridRowTemplateContext, IgxGridSelectionService, IgxGridSummaryService, IgxGridTemplateContext, IgxGridToolbarComponent, IgxGridTransaction, IgxGridValidationService, IgxHeaderCollapsedIndicatorDirective, IgxHeaderExpandedIndicatorDirective, IgxHeadSelectorDirective, IgxHeadSelectorTemplateContext, IgxRowAddTextDirective, IgxRowCollapsedIndicatorDirective, IgxRowDirective, IgxRowDragGhostDirective, IgxRowEditActionsDirective, IgxRowEditTabStopDirective, IgxRowEditTemplateDirective, IgxRowEditTextDirective, IgxRowExpandedIndicatorDirective, IgxRowSelectorDirective, IgxRowSelectorTemplateContext, IgxSortAscendingHeaderIconDirective, IgxSortDescendingHeaderIconDirective, IgxSortHeaderIconDirective, IgxSummaryRowComponent, IgxToolbarToken, IPinColumnCancellableEventArgs, IPinColumnEventArgs, IPinningConfig, IPinRowEventArgs, IRowDataCancelableEventArgs, IRowDataEventArgs, IRowDragEndEventArgs, IRowDragStartEventArgs, IRowSelectionEventArgs, IRowToggleEventArgs, ISearchInfo, ISizeInfo, ISortingEventArgs, RowEditPositionStrategy, RowPinningPosition, RowType, WatchChanges } from 'igniteui-angular/grids/core';
112112
import { getCurrentI18n, getNumberFormatter, IResourceChangeEventArgs, } from 'igniteui-i18n-core';
113113
import { I18N_FORMATTER } from 'igniteui-angular/core';
114114

@@ -7816,9 +7816,18 @@ export abstract class IgxGridBaseDirective implements GridType,
78167816
this.disableTransitions = false;
78177817

78187818
this.hideOverlays();
7819-
this.actionStrip?.hide();
7820-
if (this.actionStrip) {
7821-
this.actionStrip.context = null;
7819+
const context = this.actionStrip?.context;
7820+
const contextEl = context?.element?.nativeElement as HTMLElement;
7821+
const keepActionStrip =
7822+
!!context?.pinned &&
7823+
!!contextEl?.isConnected &&
7824+
!this.hasMenuPinningActions();
7825+
7826+
if (!keepActionStrip) {
7827+
if (this.actionStrip) {
7828+
this.actionStrip.hide();
7829+
this.actionStrip.context = null;
7830+
}
78227831
}
78237832
const args: IGridScrollEventArgs = {
78247833
direction: 'vertical',
@@ -7828,6 +7837,23 @@ export abstract class IgxGridBaseDirective implements GridType,
78287837
this.gridScroll.emit(args);
78297838
}
78307839

7840+
protected hasMenuPinningActions(): boolean {
7841+
const strip = this.actionStrip;
7842+
const actionButtons = strip?.actionButtons;
7843+
7844+
if (!actionButtons?.length) {
7845+
return false;
7846+
}
7847+
7848+
return actionButtons
7849+
.toArray()
7850+
.some(
7851+
(button) =>
7852+
button instanceof IgxGridPinningActionsComponent &&
7853+
button.asMenuItems
7854+
);
7855+
}
7856+
78317857
protected horizontalScrollHandler(event) {
78327858
const scrollLeft = event.target.scrollLeft;
78337859
this.headerContainer.onHScroll(scrollLeft);

0 commit comments

Comments
 (0)