Skip to content

Commit 8735e1b

Browse files
authored
fix(grid-pinning): remove hide call in scrollToRow - 21.1.x (#16996)
1 parent ff8db9c commit 8735e1b

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

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

@@ -7800,9 +7800,18 @@ export abstract class IgxGridBaseDirective implements GridType,
78007800
this.disableTransitions = false;
78017801

78027802
this.hideOverlays();
7803-
this.actionStrip?.hide();
7804-
if (this.actionStrip) {
7805-
this.actionStrip.context = null;
7803+
const context = this.actionStrip?.context;
7804+
const contextEl = context?.element?.nativeElement as HTMLElement;
7805+
const keepActionStrip =
7806+
!!context?.pinned &&
7807+
!!contextEl?.isConnected &&
7808+
!this.hasMenuPinningActions();
7809+
7810+
if (!keepActionStrip) {
7811+
if (this.actionStrip) {
7812+
this.actionStrip.hide();
7813+
this.actionStrip.context = null;
7814+
}
78067815
}
78077816
const args: IGridScrollEventArgs = {
78087817
direction: 'vertical',
@@ -7812,6 +7821,23 @@ export abstract class IgxGridBaseDirective implements GridType,
78127821
this.gridScroll.emit(args);
78137822
}
78147823

7824+
protected hasMenuPinningActions(): boolean {
7825+
const strip = this.actionStrip;
7826+
const actionButtons = strip?.actionButtons;
7827+
7828+
if (!actionButtons?.length) {
7829+
return false;
7830+
}
7831+
7832+
return actionButtons
7833+
.toArray()
7834+
.some(
7835+
(button) =>
7836+
button instanceof IgxGridPinningActionsComponent &&
7837+
button.asMenuItems
7838+
);
7839+
}
7840+
78157841
protected horizontalScrollHandler(event) {
78167842
const scrollLeft = event.target.scrollLeft;
78177843
this.headerContainer.onHScroll(scrollLeft);

0 commit comments

Comments
 (0)