diff --git a/packages/common/src/services/__tests__/grid.service.spec.ts b/packages/common/src/services/__tests__/grid.service.spec.ts index 460cbb133..6c01dbbfa 100644 --- a/packages/common/src/services/__tests__/grid.service.spec.ts +++ b/packages/common/src/services/__tests__/grid.service.spec.ts @@ -1091,7 +1091,7 @@ describe('Grid Service', () => { service.setPinning(mockPinning); - expect(setOptionsSpy).toHaveBeenCalledWith(mockPinning, false, true); + expect(setOptionsSpy).toHaveBeenCalledWith({ ...mockPinning, alwaysShowVerticalScroll: false }, false, true); expect(gridOptionSetterSpy).toHaveBeenCalledWith(mockPinning); expect(autosizeColumnsSpy).toHaveBeenCalled(); }); @@ -1105,7 +1105,7 @@ describe('Grid Service', () => { service.setPinning(mockPinning, false); - expect(setOptionsSpy).toHaveBeenCalledWith(mockPinning, false, true); + expect(setOptionsSpy).toHaveBeenCalledWith({ ...mockPinning, alwaysShowVerticalScroll: false }, false, true); expect(gridOptionSetterSpy).toHaveBeenCalledWith(mockPinning); expect(autosizeColumnsSpy).not.toHaveBeenCalled(); }); diff --git a/packages/common/src/services/__tests__/gridState.service.spec.ts b/packages/common/src/services/__tests__/gridState.service.spec.ts index a4053439b..2b2e56bb1 100644 --- a/packages/common/src/services/__tests__/gridState.service.spec.ts +++ b/packages/common/src/services/__tests__/gridState.service.spec.ts @@ -224,7 +224,22 @@ describe('GridStateService', () => { expect(pubSubSpy).toHaveBeenCalledWith('onFullResizeByContentRequested', { caller: 'GridStateService' }); }); - it('should call the method and expect slickgrid "setColumns" and a pubsub event "onFullResizeByContentRequested" to be called with newest columns when "triggerAutoSizeColumns" is false and "enableAutoResizeColumnsByCellContent" is true', () => { + it('should call the method and expect slickgrid "setColumns" but WITHOUT triggering pubsub event "onFullResizeByContentRequested" because it requires "enableAutoResizeColumnsByCellContent: true" AND "autosizeColumnsByCellContentOnFirstLoad: false" because this method is never called on first page load', () => { + gridOptionMock.enableAutoResizeColumnsByCellContent = true; + gridOptionMock.autosizeColumnsByCellContentOnFirstLoad = true; + jest.spyOn(SharedService.prototype, 'allColumns', 'get').mockReturnValue(allColumnsMock); + const setColsSpy = jest.spyOn(gridStub, 'setColumns'); + const autoSizeSpy = jest.spyOn(gridStub, 'autosizeColumns'); + const pubSubSpy = jest.spyOn(mockPubSub, 'publish'); + + service.changeColumnsArrangement(presetColumnsMock, false); + + expect(setColsSpy).toHaveBeenCalledWith([rowCheckboxColumnMock, ...columnsWithoutCheckboxMock]); + expect(autoSizeSpy).not.toHaveBeenCalled(); + expect(pubSubSpy).not.toHaveBeenCalledWith('onFullResizeByContentRequested', { caller: 'GridStateService' }); + }); + + it('should call the method and expect slickgrid "setColumns" and a pubsub event "onFullResizeByContentRequested" to be called with newest columns when "triggerAutoSizeColumns" is false and 3rd is set to true', () => { jest.spyOn(SharedService.prototype, 'allColumns', 'get').mockReturnValue(allColumnsMock); const setColsSpy = jest.spyOn(gridStub, 'setColumns'); const autoSizeSpy = jest.spyOn(gridStub, 'autosizeColumns'); diff --git a/packages/common/src/services/grid.service.ts b/packages/common/src/services/grid.service.ts index 689ec679e..379988510 100644 --- a/packages/common/src/services/grid.service.ts +++ b/packages/common/src/services/grid.service.ts @@ -96,8 +96,12 @@ export class GridService { * @param {Boolean} suppressColumnSet - do we want to supress the columns set, via "setColumns()" method? (defaults to false) */ setPinning(pinningOptions: CurrentPinning, shouldAutosizeColumns = true, suppressRender = false, suppressColumnSet = true) { - this.sharedService.slickGrid.setOptions(pinningOptions, suppressRender, suppressColumnSet); - this.sharedService.gridOptions = { ...this.sharedService.gridOptions, ...pinningOptions }; + const options = pinningOptions as GridOption; + if (typeof pinningOptions?.frozenColumn === 'number' && pinningOptions.frozenColumn >= 0) { + options.alwaysShowVerticalScroll = false; // make sure to never show the verticall scroll when the grid has pinning (frozen column) + } + this.sharedService.slickGrid.setOptions(options, suppressRender, suppressColumnSet); + this.sharedService.gridOptions = { ...this.sharedService.gridOptions, ...options }; if (shouldAutosizeColumns) { this.sharedService.slickGrid.autosizeColumns(); diff --git a/packages/common/src/services/gridState.service.ts b/packages/common/src/services/gridState.service.ts index f402b3509..a09741ad2 100644 --- a/packages/common/src/services/gridState.service.ts +++ b/packages/common/src/services/gridState.service.ts @@ -129,7 +129,7 @@ export class GridStateService { // resize the columns to fit the grid canvas if (triggerAutoSizeColumns) { this._grid.autosizeColumns(); - } else if (triggerColumnsFullResizeByContent || this._gridOptions.enableAutoResizeColumnsByCellContent) { + } else if (triggerColumnsFullResizeByContent || (this._gridOptions.enableAutoResizeColumnsByCellContent && !this._gridOptions.autosizeColumnsByCellContentOnFirstLoad)) { this.pubSubService.publish('onFullResizeByContentRequested', { caller: 'GridStateService' }); } } diff --git a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip index 1e79f8775..813b50ee9 100644 Binary files a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip and b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip differ