Behavior of selected row when a row is removed from a sorted table

I have a table of data displayed in my retool app. I sometimes do an action that ends up removing the selected row and refreshing the query that populates the table. When this happens, the new selected row is the next one in the query, ignoring any sort I currently have applied to the table. So the selected record may not even be on the same page I'm currently on in the table, which is really confusing. Is there a way I can make it move the selected row to the next one according to the current sort/filters applied on the table?

For example, in the table below, if I deleted the currently selected row (row 1 on page 6) and refreshed the data, the selected row would now be row 2 on page 10 instead of row 1 on page 6, which is what I would expect/want it to do. Because it selects the next row based on the underlying query, rather than what I actually see in the table right now.

Hi @shinyllama Thanks for reaching out about this! I'm wondering if you can use the control components events to select the page & row that you're expecting? You could trigger these events on success of the get data request for the table

For example, this event always resets the table to the first page.

Let me know if you think this could work!