AG Grid rows appear selected after refreshing data

I have a dash app that contains an AG Grid. The rows in this grid are selectable. The user can refresh the data in the grid by clicking a button. The grid is stored in a standard HTML Div, and the children property of this div is updated in the callback by recreating the grid. The refresh is successful, as the grid reflects changes made in the backend data.
This is the code for defining the grid:

data_table = dag.AgGrid(
            id=f'datagrid',
            rowData=some_data,
            columnDefs=columnDefs,
            defaultColDef={
                'resizable': True,
                'sortable': True,
                'filter': True,
            },
            columnSize='sizeToFit',
            dashGridOptions={"rowSelection": "multiple", "rowMultiSelectWithClick": True, "columnHoverHighlight": True},
            style={"height": "100%", "width": "100%"},
            getRowId="params.data.id_value",  
            className='ag-theme-alpine order-grid',
        )

The problem is that the selectedRows property of the grid is emptied when refreshing the data, while the rows still appear to be selected visually. This can obviously confuse the user, because any callback that relies on the selectedRows property functions differently than expected.

Ideally, I would like the selectedRows property to reflect the visually selected rows, but it is also fine to visually deselect the rows after refreshing the grid. How can I achieve this?

Hello @rob_cl,

What version of Dash AG Grid are you using?

Also, do you have an MRE that you can give that includes the mechanism to refresh?