From a6cd2cbd5b3f4121e0ccf6844d5dca46f3f91a43 Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Thu, 18 Jun 2026 16:25:53 -0700 Subject: [PATCH] Guard against null gridApi in onSortChanged Signed-off-by: Sai Asish Y --- CHANGELOG.md | 2 ++ src/lib/fragments/AgGrid.react.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fe2e872..9dc70228 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). Links "DE#nnn" prior to version 2.0 point to the Dash Enterprise closed-source Dash AG Grid repo ## [unreleased] +### Fixed +- [#466](https://github.com/plotly/dash-ag-grid/issues/466) guard against a null `gridApi` in `onSortChanged`, which threw an uncaught `TypeError` when a grid initialized with a sort applied via `initialState.sort.sortModel` ## [33.3.3] - 2025-12-19 ### Fixed diff --git a/src/lib/fragments/AgGrid.react.js b/src/lib/fragments/AgGrid.react.js index c8d900c7..49c1c3f5 100644 --- a/src/lib/fragments/AgGrid.react.js +++ b/src/lib/fragments/AgGrid.react.js @@ -738,7 +738,7 @@ export function DashAgGrid(props) { if (rowModelType === 'clientSide') { propsToSet.virtualRowData = virtualRowData(); } - if (!gridApi.isDestroyed()) { + if (gridApi && !gridApi?.isDestroyed()) { propsToSet.columnState = JSON.parse( JSON.stringify(gridApi.getColumnState()) );