Skip to content

Commit 9e90eb8

Browse files
authored
fix: auto-resize not just grid but also headers for Salesforce tabs (#1394)
* fix: auto-resize not just grid but also headers for Salesforce tabs - when switching Tabs in Salesforce, SlickGrid has problem resizing properly, a prior auto-resize patch was put in place some time ago to call `resizeGrid()` for certain period, but with v3.0 that didn't seem to be enough since the headers were not being resized properly, so let's resize them too by calling `grid.updateColumns()` in the same auto-resize function
1 parent f3ec760 commit 9e90eb8

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

packages/common/src/interfaces/slickGrid.interface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export interface SlickGrid {
110110
getActiveViewportNode(event?: Event | SlickGridEventData): HTMLDivElement;
111111

112112
/** Get the displayed scrollbar dimensions */
113-
getDisplayedScrollbarDimensions(): { height: number; width: number; }
113+
getDisplayedScrollbarDimensions(): { height: number; width: number; };
114114

115115
/** Get the canvas DOM element */
116116
getCanvases(): HTMLDivElement;
@@ -478,6 +478,9 @@ export interface SlickGrid {
478478
*/
479479
updateColumnHeader(columnId: string | number, title?: string, toolTip?: string): void;
480480

481+
/** Update columns for when a hidden property has changed but the column list itself has not changed. */
482+
updateColumns(): void;
483+
481484
/** Update paging information status from the View */
482485
updatePagingStatusFromView(pagingInfo: PagingInfo): void;
483486

packages/common/src/services/__tests__/resizer.service.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const gridStub = {
5454
setPreHeaderPanelVisibility: jest.fn(),
5555
setOptions: jest.fn(),
5656
setSortColumns: jest.fn(),
57+
updateColumns: jest.fn(),
5758
onColumnsResizeDblClick: new Slick.Event(),
5859
onSort: new Slick.Event(),
5960
} as unknown as SlickGrid;

packages/common/src/services/resizer.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@ export class ResizerService {
685685
// visible grid (shown to the user and not hidden in another Tab will have an offsetParent defined)
686686
if (this.checkIsGridShown() && (isResizeRequired || containerElmOffset?.left === 0 || containerElmOffset?.top === 0)) {
687687
await this.resizeGrid();
688+
if (resizeGoodCount < 5) {
689+
this._grid.updateColumns(); // also refresh header titles after grid becomes visible in new tab, this fixes an issue observed in Salesforce
690+
}
688691

689692
// make sure the grid is still visible after doing the resize
690693
if (this.checkIsGridShown()) {
Binary file not shown.

0 commit comments

Comments
 (0)