Skip to content

Commit faf9104

Browse files
authored
Merge branch 'master' into fluent-theme
2 parents 863c46a + fd29519 commit faf9104

File tree

3 files changed

+40
-16
lines changed

3 files changed

+40
-16
lines changed

projects/igniteui-angular/src/lib/directives/drag-drop/drag-drop.directive.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
942942

943943
const totalMovedX = pageX - this._startX;
944944
const totalMovedY = pageY - this._startY;
945-
this._dragGhostHostX = this.dragGhostHost ? this.getdragGhostHostOffsetLeft(this.dragGhostHost) : 0;
946-
this._dragGhostHostY = this.dragGhostHost ? this.getdragGhostHostOffsetTop(this.dragGhostHost) : 0;
945+
this._dragGhostHostX = this.dragGhostHost ? this.getDragGhostHostOffsetLeft(this.dragGhostHost) : 0;
946+
this._dragGhostHostY = this.dragGhostHost ? this.getDragGhostHostOffsetTop(this.dragGhostHost) : 0;
947947

948948
this.dragGhost.style.transitionDuration = '0.0s';
949949
this.dragGhost.style.position = 'absolute';
@@ -1220,21 +1220,21 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
12201220
return window.scrollX ? window.scrollX : (window.pageXOffset ? window.pageXOffset : 0);
12211221
}
12221222

1223-
protected getdragGhostHostOffsetLeft(dragGhostHost: any) {
1224-
if (dragGhostHost.computedStyleMap().get('position').value === 'static' &&
1225-
dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
1223+
protected getDragGhostHostOffsetLeft(dragGhostHost: any) {
1224+
const ghostPosition = document.defaultView.getComputedStyle(dragGhostHost).getPropertyValue('position');
1225+
if (ghostPosition === 'static' && dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
12261226
return 0;
1227-
} else if (dragGhostHost.computedStyleMap().get('position').value === 'static' && dragGhostHost.offsetParent) {
1227+
} else if (ghostPosition === 'static' && dragGhostHost.offsetParent) {
12281228
return dragGhostHost.offsetParent.getBoundingClientRect().left;
12291229
}
12301230
return dragGhostHost.getBoundingClientRect().left;
12311231
}
12321232

1233-
protected getdragGhostHostOffsetTop(dragGhostHost: any) {
1234-
if (dragGhostHost.computedStyleMap().get('position').value === 'static' &&
1235-
dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
1233+
protected getDragGhostHostOffsetTop(dragGhostHost: any) {
1234+
const ghostPosition = document.defaultView.getComputedStyle(dragGhostHost).getPropertyValue('position');
1235+
if (ghostPosition === 'static' && dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
12361236
return 0;
1237-
} else if (dragGhostHost.computedStyleMap().get('position').value === 'static' && dragGhostHost.offsetParent) {
1237+
} else if (ghostPosition === 'static' && dragGhostHost.offsetParent) {
12381238
return dragGhostHost.offsetParent.getBoundingClientRect().top;
12391239
}
12401240
return dragGhostHost.getBoundingClientRect().top;

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
AbsoluteScrollStrategy
2222
} from '../services/index';
2323
import { GridBaseAPIService } from './api.service';
24+
import { IgxButtonDirective } from '../directives/button/button.directive';
2425
import { IgxGridBaseComponent, IGridDataBindable } from './grid-base.component';
2526
import { IgxDropDownComponent } from '../drop-down/drop-down.component';
2627
import { IgxColumnHidingComponent } from './column-hiding.component';
@@ -104,8 +105,8 @@ export class IgxGridToolbarComponent extends DisplayDensityBase {
104105
* const hidingButton = this.grid.toolbar.columnHidingButton;
105106
* ```
106107
*/
107-
@ViewChild('columnHidingButton', { static: false })
108-
public columnHidingButton;
108+
@ViewChild('columnHidingButton', { read: IgxButtonDirective, static: false })
109+
public columnHidingButton: IgxButtonDirective;
109110

110111
/**
111112
* Provides a reference to the `IgxDropDownComponent` of the Export button.
@@ -122,8 +123,8 @@ export class IgxGridToolbarComponent extends DisplayDensityBase {
122123
* const exportBtn = this.grid.toolbar.exportButton;
123124
* ```
124125
*/
125-
@ViewChild('btnExport', { static: false })
126-
public exportButton;
126+
@ViewChild('btnExport', { read: IgxButtonDirective, static: false })
127+
public exportButton: IgxButtonDirective;
127128

128129
/**
129130
* Provides a reference to the `IgxDropDownComponent` of the Column Pinning UI.
@@ -149,8 +150,8 @@ export class IgxGridToolbarComponent extends DisplayDensityBase {
149150
* const pinningButton = this.grid.toolbar.columnPinningButton;
150151
* ```
151152
*/
152-
@ViewChild('columnPinningButton', { static: false })
153-
public columnPinningButton;
153+
@ViewChild('columnPinningButton', { read: IgxButtonDirective, static: false })
154+
public columnPinningButton: IgxButtonDirective;
154155

155156
/**
156157
* Returns a reference to the `IgxGridComponent` component, hosting the `IgxGridToolbarComponent`.

projects/igniteui-angular/src/lib/grids/grid/grid-toolbar.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { first } from 'rxjs/operators';
66
import { IgxCsvExporterOptions, IgxCsvExporterService, IgxExcelExporterOptions, IgxExcelExporterService } from '../../services/index';
7+
import { IgxButtonDirective } from '../../directives/button/button.directive';
78
import { IgxGridComponent } from './grid.component';
89
import { IgxGridModule } from './index';
910
import { DisplayDensity } from '../../core/displayDensity';
@@ -582,6 +583,28 @@ describe('IgxGrid - Grid Toolbar Custom Content', () => {
582583
expect(customContainer).not.toBe(null);
583584
});
584585

586+
it('should expose the toolbar buttons with their correct type', () => {
587+
fixture = TestBed.createComponent(GridToolbarTestPage1Component);
588+
fixture.detectChanges();
589+
grid = fixture.componentInstance.grid1;
590+
591+
grid.showToolbar = true;
592+
grid.columnHiding = true;
593+
grid.columnPinning = true;
594+
grid.exportExcel = true;
595+
grid.exportCsv = true;
596+
fixture.detectChanges();
597+
598+
let aButton = grid.toolbar.columnHidingButton;
599+
expect(aButton instanceof IgxButtonDirective).toBe(true, 'column hiding button has wrong type');
600+
601+
aButton = grid.toolbar.columnPinningButton;
602+
expect(aButton instanceof IgxButtonDirective).toBe(true, 'column pinning button has wrong type');
603+
604+
aButton = grid.toolbar.exportButton;
605+
expect(aButton instanceof IgxButtonDirective).toBe(true, 'export button has wrong type');
606+
});
607+
585608
});
586609

587610
function getToolbar(fixture) {

0 commit comments

Comments
 (0)