-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
DataTable: Resizing headers in expand mode does not work correctly #3970
Comments
yeah I'll take a look at submitting a PR for PrimeReact for the one I tested. |
Hope the fix of this issue is not available in version 9 |
it is not. it looks like it is slated for the 10.0.0 milestone. |
This bug was fixed in PrimeReact, but is still there in PrimeVue (https://github.com/primefaces/primevue/blob/4754753cf264b2d7370b89599dad38df2cb7c2dd/components/lib/datatable/DataTable.vue#L1242). |
@1Map why not submit a PrimeVue PR porting this fix? |
I did (primefaces/primevue#4276), not sure how long until someone merge it back into their master branch? |
@melloware Was this bug really fixed in PrimeReact? Reason why I ask is: If I navigate to: https://primereact.org/datatable/#resize_expandmode It still behaves wrong. |
Describe the bug
See the example of this problem in action directly in the demo on primefaces.org:
https://www.primefaces.org/primereact/datatable/colresize/
Tried this on a Mac OS 12.6.2 using:
I investigated this issue further and found the root case.
In DataTable.js, there is a function
onColumnResizeEnd
. This function is called when the user drags and drops the resizer to the right. Within this function, when column size mode is 'expand', it attempts to do two things:Here is the code snippet for this portion:
The problem:
Note that it uses 'getOuterWidth' -- which corresponds to offsetWidth.
So if you made a DataTable that had a width of 300px, and you had headers with 100px 100px 100px, and then you resized #2 by 50px, you would have something like this:
Solution #1: reorder calls:
This works and looks good, but I don't know if it could have other side effects for people with different parameters on their code.
Solution #2: calculate new column width AFTER the updateTableWidth call
I haven't tested this solution, but in theory it should have a similar effect.
Reproducer
No response
PrimeReact version
8.7.0
React version
17.x
Language
TypeScript
Build / Runtime
Next.js
Browser(s)
Safari 16.2,Chrome
Steps to reproduce the behavior
Actual: The Code column and also the other columns after Name also changes size slightly. Not by as much as you resize the Name column, but it always changes, and it changes more if you resize Name more. This also happens for any other column aside from the first one. The end result is the column doesn't end up where you dragged it.
This only seems to be a problem with Expand Mode -- Fit mode works correctly.
Expected behavior
Name column resized to the exact spot where you dragged it, all other columns to the right shifted by that amount but not resized, all other columns to the left untouched.
The text was updated successfully, but these errors were encountered: