Skip to content

Commit 1767a7b

Browse files
authored
fix: column resize inside sheet (#351)
* fix: column resize inside sheet * fix: test
1 parent 745637e commit 1767a7b

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

projects/components/src/table/table.component.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fakeAsync } from '@angular/core/testing';
22
import { ActivatedRoute, convertToParamMap } from '@angular/router';
3-
import { NavigationService } from '@hypertrace/common';
3+
import { DomElementMeasurerService, NavigationService } from '@hypertrace/common';
44
import {
55
CoreTableCellRendererType,
66
LetAsyncModule,
@@ -65,6 +65,16 @@ describe('Table component', () => {
6565
mockProvider(ActivatedRoute, {
6666
queryParamMap: EMPTY
6767
}),
68+
mockProvider(DomElementMeasurerService, {
69+
measureHtmlElement: (): ClientRect => ({
70+
top: 0,
71+
left: 0,
72+
bottom: 20,
73+
right: 200,
74+
height: 20,
75+
width: 200
76+
})
77+
}),
6878
mockProvider(TableService, {
6979
buildExtendedColumnConfigs: (columnConfigs: TableColumnConfig[]) => columnConfigs as TableColumnConfigExtended[]
7080
})

projects/components/src/table/table.component.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ import {
1515
ViewChild
1616
} from '@angular/core';
1717
import { ActivatedRoute, ParamMap } from '@angular/router';
18-
import { isEqualIgnoreFunctions, NavigationService, NumberCoercer, TypedSimpleChanges } from '@hypertrace/common';
18+
import {
19+
DomElementMeasurerService,
20+
isEqualIgnoreFunctions,
21+
NavigationService,
22+
NumberCoercer,
23+
TypedSimpleChanges
24+
} from '@hypertrace/common';
1925
import { without } from 'lodash-es';
2026
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
2127
import { filter, map } from 'rxjs/operators';
@@ -336,6 +342,7 @@ export class TableComponent
336342
private readonly changeDetector: ChangeDetectorRef,
337343
private readonly navigationService: NavigationService,
338344
private readonly activatedRoute: ActivatedRoute,
345+
private readonly domElementMeasurerService: DomElementMeasurerService,
339346
private readonly tableService: TableService
340347
) {
341348
combineLatest([this.activatedRoute.queryParamMap, this.columnConfigs$])
@@ -437,19 +444,16 @@ export class TableComponent
437444

438445
private buildColumnInfo(index: number): ColumnInfo {
439446
const element = this.queryHeaderCellElement(index);
447+
const boundingBox = this.domElementMeasurerService.measureHtmlElement(element);
440448

441449
return {
442450
config: this.getVisibleColumnConfig(index),
443451
element: element,
444-
bounds: this.calcBounds(element)
445-
};
446-
}
447-
448-
private calcBounds(element: HTMLElement): ColumnBounds {
449-
// We add additional padding so a portion of the column remains visible to resize (asymmetry due to resize-handle)
450-
return {
451-
left: element.offsetLeft + 12,
452-
right: element.offsetLeft + element.offsetWidth - 8
452+
bounds: {
453+
// We add additional padding so a portion of the column remains visible to resize (asymmetry due to resize-handle)
454+
left: boundingBox.left + 12,
455+
right: boundingBox.left + boundingBox.width - 8
456+
}
453457
};
454458
}
455459

0 commit comments

Comments
 (0)