Skip to content

Commit 9114d23

Browse files
authored
Merge pull request #5499 from IgniteUI/AMarinov/issue5421_81
fix(row-drag): un-needed horizontal scroll bar on the grid
2 parents 5f47445 + dc55def commit 9114d23

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,6 +3321,10 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
33213321
return this.rowSelectable && this.hasVisibleColumns;
33223322
}
33233323

3324+
get showDragIcons(): boolean {
3325+
return this.rowDraggable && this.columns.length > this.hiddenColumnsCount;
3326+
}
3327+
33243328
/**
33253329
* @hidden
33263330
*/
@@ -4198,6 +4202,10 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
41984202
computedWidth -= this.headerCheckboxContainer ? this.headerCheckboxContainer.nativeElement.offsetWidth : 0;
41994203
}
42004204

4205+
if (this.showDragIcons) {
4206+
computedWidth -= this.headerDragContainer ? this.headerDragContainer.nativeElement.offsetWidth : 0;
4207+
}
4208+
42014209
const visibleChildColumns = this.visibleColumns.filter(c => !c.columnGroup);
42024210

42034211

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,11 @@ describe('IgxGrid - Row Drag Tests', () => {
240240
grid.rowSelectable = true;
241241
grid.rowDraggable = true;
242242
fixture.detectChanges();
243-
rowSelectElement = fixture.debugElement.query(By.css(CSS_CLASS_SELECTION_CHECKBOX));
244-
dragIndicatorElement = fixture.debugElement.query(By.css('.' + CSS_CLASS_DRAG_INDICATOR));
245243
horizontalScrollbarElement = fixture.debugElement.query(By.css(CSS_CLASS_VIRTUAL_HSCROLLBAR));
246-
const rowSelectRect = rowSelectElement.nativeElement.getBoundingClientRect();
247244
horizontalScrollbarRect = horizontalScrollbarElement.nativeElement.getBoundingClientRect();
248-
expect(rowSelectRect.right).toBe(horizontalScrollbarRect.left);
245+
246+
// The horizontal scrollbar should not be visible
247+
expect(horizontalScrollbarRect.left).toBe(0);
249248
}));
250249
it('should align horizontal scrollbar with first non-pinned column when column pinning is enabled', fakeAsync(() => {
251250
grid.pinColumn('ProductName');
@@ -257,7 +256,9 @@ describe('IgxGrid - Row Drag Tests', () => {
257256
let horizontalScrollbarRect = horizontalScrollbarElement.nativeElement.getBoundingClientRect();
258257
let pinnedColumnHeaderElement: DebugElement = fixture.debugElement.query(By.css('.' + CSS_CLASS_LAST_PINNED_HEADER));
259258
let pinnedColumnHeaderRect = pinnedColumnHeaderElement.nativeElement.getBoundingClientRect();
260-
expect(pinnedColumnHeaderRect.right).toBe(horizontalScrollbarRect.left);
259+
260+
// The horizontal scrollbar should not be visible
261+
expect(horizontalScrollbarRect.left).toBe(0);
261262

262263
// selectable rows enabled
263264
grid.rowSelectable = true;

0 commit comments

Comments
 (0)