Skip to content

Commit 224ea62

Browse files
committed
Fix bug setting columnState prop
1 parent a7534ee commit 224ea62

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/lib/fragments/AgGrid.react.js

Lines changed: 9 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,16 @@ 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 realStateChange =
1437+
props.columnState &&
1438+
!equals(props.columnState, existingColumnState);
1439+
1440+
if (realStateChange && !columnState_push) {
14381441
setColumnState_push(true);
14391442
}
14401443
}
1441-
}, [props.columnState, props.loading_state, gridApi, columnState_push]);
1444+
}, [props.columnState, props.loading_state, columnState_push]);
14421445

14431446
// Handle ID changes
14441447
useEffect(() => {
@@ -1578,9 +1581,7 @@ export function DashAgGrid(props) {
15781581
if (props.updateColumnState) {
15791582
updateColumnState();
15801583
} else if (columnState_push) {
1581-
setTimeout(() => {
1582-
setColumnState();
1583-
}, 1);
1584+
setColumnState();
15841585
}
15851586
}
15861587
}, [

tests/test_column_state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ def loadState(n):
247247
)
248248

249249
dash_duo.find_element("#load-column-defs").click()
250+
251+
time.sleep(0.5) # pausing to emulate separation because user inputs
252+
250253
until(
251254
lambda: json.dumps(alt_colState)
252255
in dash_duo.find_element("#reset-column-state-grid-pre").text,

0 commit comments

Comments
 (0)