Table: Row selection is not cleaned up when table data is removed. #5850
Open
Description
TanStack Table version
8.20.6
Framework/Library version
latest
Describe the bug and the steps to reproduce it
I'd expect some easy api's to remove selection by id and or some guidelines ho to maintain state when you know data is being removed. In my case I have web sockets that tell me data is being removed, and I want to ensure selection is in a good state (as I'm doing complex things like skipping refresh if there is a selection).
I modified the same here: https://tanstack.com/table/latest/docs/framework/react/examples/row-selection Just paste in this code, make a selection and then hit refresh data.
import { faker } from '@faker-js/faker';
export type Person = {
id: number;
firstName: string;
lastName: string;
age: number;
visits: number;
progress: number;
status: 'relationship' | 'complicated' | 'single';
subRows?: Person[];
};
const range = (len: number) => {
const arr: number[] = [];
for (let i = 0; i < len; i++) {
arr.push(i);
}
return arr;
};
const newPerson = (): Person => {
return {
id: faker.number.int(40) + 1000,
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
age: faker.number.int(40),
visits: faker.number.int(1000),
progress: faker.number.int(100),
status: faker.helpers.shuffle<Person['status']>([
'relationship',
'complicated',
'single',
])[0]!,
};
};
export function makeData(...lens: number[]) {
const makeDataLevel = (): Person[] => {
return range(1).map((): Person => {
return {
...newPerson(),
};
});
};
return makeDataLevel();
}
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://tanstack.com/table/latest/docs/framework/react/examples/row-selection
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Metadata
Assignees
Labels
No labels