jbetancur / react-data-table-component

A responsive table library with built-in sorting, pagination, selection, expandable rows, and customizable styling.
https://react-data-table-component.netlify.app
Apache License 2.0
2.06k stars 413 forks source link

Column Width and Position Shifting During Pagination and Sorting #1261

Open r-jacko opened 1 week ago

r-jacko commented 1 week ago

Issue Check list

Describe the bug

If the component has pagination enabled, switching between different pages can sometimes cause column widths to change. However, the bigger issue arises when sorting is enabled. If a user clicks on a column to sort it, after the sorting function is executed, a completely different column may end up under their cursor. This issue occurs especially in tables with narrow columns (e.g., displaying short numeric data) or tables with a large number of columns.

To Reproduce

Steps to reproduce the behavior:

  1. Open the default sandbox assigned to the GitHub issue template.
  2. Adjust the slider separating the code view and preview.
  3. Click on the 'Director' column to trigger sorting.
  4. Notice how the columns change their width and their position along the X-axis.

Expected behavior

Columns should retain their width and position during both sorting and page changes in pagination. This is probably not feasible for server-side pagination, but maybe it can be adjusted when that option is disabled.

Code Sandbox, Screenshots, or Relevant Code

Default sandbox.

Here the issue is demonstrated on a smaller section of a larger table (1920px width monitor, just a lot of data) ezgif-3-78de8edc85 ezgif-3-47fc69f2e2

Versions (please complete the following information)