Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected row index remains when moving #2

Open
rickysullivan opened this issue Jun 26, 2024 · 2 comments
Open

Selected row index remains when moving #2

rickysullivan opened this issue Jun 26, 2024 · 2 comments

Comments

@rickysullivan
Copy link

Describe the bug

The selected row index remains, not the selected row.

ScreenRecording_06-27-2024.08-13-38_1.mp4

Basically the row you selected doesn’t remain selected.

How to reproduce

Select a row. Then sort the rows.

Link to reproduction

https://sortable.sadmn.com/data-table

Additional information

No response

@kravis-lau
Copy link

You need to assign a unique key (like uuid) for each row. Add this to your useReactTable options:

const table = useReactTable({
  // ...
  // Redefine the row ID so that the row can still be correctly located after CRUD operations
  getRowId: (row) => row.uuid,
  // ...
});

@sadmann7
Copy link
Owner

by using unique id, it will also stop jumping around after dropping to a new position

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants