Skip to content

Commit c2109e4

Browse files
committed
Fix bug with initial selections
1 parent 4e1b551 commit c2109e4

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/lib/fragments/AgGrid.react.js

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,8 +1285,10 @@ export function DashAgGrid(props) {
12851285

12861286
useEffect(() => {
12871287
// Apply selections
1288-
setSelection(props.selectedRows);
1289-
}, [props.selectedRows]);
1288+
if (gridApi) {
1289+
setSelection(props.selectedRows);
1290+
}
1291+
}, [props.selectedRows, gridApi]);
12901292

12911293
// 1. Handle gridApi initialization - basic setup
12921294
useEffect(() => {
@@ -1479,27 +1481,6 @@ export function DashAgGrid(props) {
14791481
props.detailCellRendererParams,
14801482
]);
14811483

1482-
// 6. Handle selectedRows changes
1483-
useEffect(() => {
1484-
if (
1485-
!equals(props.selectedRows, prevProps?.selectedRows) &&
1486-
!(typeof props.loading_state !== 'undefined'
1487-
? props.loading_state && selectionEventFired.current
1488-
: selectionEventFired.current)
1489-
) {
1490-
if (!dataUpdates.current) {
1491-
setTimeout(() => {
1492-
if (!dataUpdates.current) {
1493-
setSelection(props.selectedRows);
1494-
}
1495-
}, 10);
1496-
}
1497-
}
1498-
1499-
// Reset selection event flag
1500-
selectionEventFired.current = false;
1501-
}, [props.selectedRows, props.loading_state]);
1502-
15031484
// 7. Handle dataUpdates reset
15041485
useEffect(() => {
15051486
dataUpdates.current = false;

0 commit comments

Comments
 (0)