diff --git a/packages/pluggableWidgets/datagrid-web/CHANGELOG.md b/packages/pluggableWidgets/datagrid-web/CHANGELOG.md index 7144838bb3..aaa0fcd919 100644 --- a/packages/pluggableWidgets/datagrid-web/CHANGELOG.md +++ b/packages/pluggableWidgets/datagrid-web/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed + +- We fixed an issue where clearing a grid would cause wrong column grid calculation, causing unwanted scroll bars. + ## [3.8.1] - 2026-02-19 ### Fixed diff --git a/packages/pluggableWidgets/datagrid-web/src/model/containers/Datagrid.container.ts b/packages/pluggableWidgets/datagrid-web/src/model/containers/Datagrid.container.ts index 2493dfe82c..57ccffacb1 100644 --- a/packages/pluggableWidgets/datagrid-web/src/model/containers/Datagrid.container.ts +++ b/packages/pluggableWidgets/datagrid-web/src/model/containers/Datagrid.container.ts @@ -48,7 +48,7 @@ injected(DatasourceParamsController, CORE.setupService, DG.query, DG.combinedFil injected(DatasourceService, CORE.setupService, DG.queryGate, DG.refreshInterval.optional); injected(GridBasicData, CORE.mainGate); injected(WidgetRootViewModel, CORE.mainGate, CORE.config, DG.exportProgressService, SA_TOKENS.selectionDialogVM); -injected(GridSizeStore, CORE.atoms.hasMoreItems, DG.paginationConfig, DG.setPageAction); +injected(GridSizeStore, CORE.atoms.hasMoreItems, CORE.atoms.itemCount, DG.paginationConfig, DG.setPageAction); /** Pagination **/ injected(createSetPageAction, DG.query, DG.paginationConfig, DG.currentPage, DG.pageSize); diff --git a/packages/pluggableWidgets/datagrid-web/src/model/stores/GridSize.store.ts b/packages/pluggableWidgets/datagrid-web/src/model/stores/GridSize.store.ts index f894cc2bbf..8bb1f7730b 100644 --- a/packages/pluggableWidgets/datagrid-web/src/model/stores/GridSize.store.ts +++ b/packages/pluggableWidgets/datagrid-web/src/model/stores/GridSize.store.ts @@ -18,6 +18,7 @@ export class GridSizeStore { constructor( private readonly hasMoreItemsAtom: ComputedAtom, + private readonly itemCountAtom: ComputedAtom, private readonly paginationConfig: PaginationConfig, private readonly setPageAction: SetPageAction ) { @@ -75,6 +76,15 @@ export class GridSizeStore { } updateColumnSizes(sizes: number[]): void { + const itemCount = this.itemCountAtom.get(); + + // If grid is empty, always clear columnSizes to use natural CSS grid layout + // This ensures empty grids behave consistently whether freshly rendered or emptied + if (itemCount === 0) { + this.columnSizes = undefined; + return; + } + this.columnSizes = sizes; }