Skip to content

Commit 88bef0c

Browse files
committed
Fix bug setting columnState prop
1 parent a7534ee commit 88bef0c

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/lib/fragments/AgGrid.react.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@ export function DashAgGrid(props) {
14161416
// Hydrate virtualRowData and finalize setup
14171417
onFilterChanged(true);
14181418
updateColumnState();
1419+
setColumnState_push(false);
14191420
}
14201421
}, [
14211422
gridApi,
@@ -1431,14 +1432,19 @@ export function DashAgGrid(props) {
14311432
gridApi &&
14321433
(!props.loading_state || prevProps?.loading_state?.is_loading)
14331434
) {
1434-
if (
1435-
props.columnState !== prevProps?.columnState &&
1436-
!columnState_push
1437-
) {
1435+
const existingColumnState = gridApi.getColumnState();
1436+
const propChanged =
1437+
props.columnState &&
1438+
!equals(props?.columnState, prevProps?.columnState);
1439+
const realStateChange =
1440+
props.columnState &&
1441+
!equals(props.columnState, existingColumnState);
1442+
1443+
if (propChanged && realStateChange && !columnState_push) {
14381444
setColumnState_push(true);
14391445
}
14401446
}
1441-
}, [props.columnState, props.loading_state, gridApi, columnState_push]);
1447+
}, [props.columnState, props.loading_state, columnState_push]);
14421448

14431449
// Handle ID changes
14441450
useEffect(() => {
@@ -1578,9 +1584,7 @@ export function DashAgGrid(props) {
15781584
if (props.updateColumnState) {
15791585
updateColumnState();
15801586
} else if (columnState_push) {
1581-
setTimeout(() => {
1582-
setColumnState();
1583-
}, 1);
1587+
setColumnState();
15841588
}
15851589
}
15861590
}, [

0 commit comments

Comments
 (0)