Fix uncaught TypeError in onSortChanged when grid initializes with a sort#473
Closed
budescode wants to merge 1 commit into
Closed
Fix uncaught TypeError in onSortChanged when grid initializes with a sort#473budescode wants to merge 1 commit into
budescode wants to merge 1 commit into
Conversation
…sort AG Grid fires sortChanged from its async event queue during grid init when dashGridOptions.initialState.sort.sortModel is set, before the component's gridApi state has been assigned. onSortChanged was the only event handler dereferencing gridApi without a null guard, producing one uncaught 'Cannot read properties of null (reading isDestroyed)' error per grid on page load. Early-return when gridApi is null, matching the existing pattern in onFilterChanged. Fixes plotly#466
|
Collaborator
|
Sorry, this is a duplicate and has been fixed on v35, I can pull back to v33 if you need it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #466
Problem
When a grid is created with a sort in
dashGridOptions.initialState.sort.sortModel,AG Grid fires
sortChangedfrom its async event queue during init before thecomponent's
gridApistate has been assigned.onSortChangedwas the only eventhandler dereferencing
gridApiwithout a null guard, so every such grid logged oneuncaught
TypeError: Cannot read properties of null (reading 'isDestroyed')on page load.Fix
Early-return from
onSortChangedwhengridApiis null, matching the existingpattern in
onFilterChanged. This also avoids sending a spuriousvirtualRowData=[]update to Dash during init.Verification
Reproduced with a minimal app (3-row grid with an
initialStatesort) ondash-ag-grid 35.2.0: one uncaught TypeError per page load. After this patch
(rebuilt locally, installed with
pip install -e .): console is clean and thegrid renders with the initial sort correctly applied.