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

Datatable: scrollable property loses column alignment #3091

Closed
Dav3rs opened this issue Jul 21, 2022 · 11 comments
Closed

Datatable: scrollable property loses column alignment #3091

Dav3rs opened this issue Jul 21, 2022 · 11 comments

Comments

@Dav3rs
Copy link

Dav3rs commented Jul 21, 2022

Describe the bug

This occurs just by adding the scrollable property when cell values are very different each others:
image

Just by removing the "scrollable" property:
image

Check the next sandbox:
image

Reproducer

https://codesandbox.io/embed/great-monad-pzyj6p?fontsize=14&hidenavigation=1&theme=dark

PrimeReact version

8.3.0

React version

18.x

Language

TypeScript

Build / Runtime

Next.js

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

Keep the column alignment.

@Dav3rs Dav3rs added Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Type: Bug Issue contains a defect related to a specific component. labels Jul 21, 2022
@melloware melloware added 👍 confirmed and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jul 21, 2022
@melloware melloware changed the title Datatable: scrollable property make to loose the column alignment Datatable: scrollable property loses column alignment Jul 21, 2022
@riyasat
Copy link

riyasat commented Jul 22, 2022

Hi,
There is also one more bug related to the scrollable.
When you make datatable as scrollable you cannot set the column width. You can reproduce it on same link as mentioned in the bug report by adding style={{width:'3em'}}.

Regards

@melloware melloware added this to the 9.0.0 milestone Jul 22, 2022
@ubau
Copy link

ubau commented Jul 22, 2022

Simple workaround for this issue is to set min width for every column.
You can try it in same reproducer just by adding style={{minWidth: "100px"}}

@melloware melloware added the Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team label Jul 22, 2022
@melloware
Copy link
Member

melloware commented Jul 22, 2022

@Dav3rs
Copy link
Author

Dav3rs commented Jul 22, 2022

@melloware That is a workaround for the with style issue, but not for the main ticket issue, because if I set some harcoded min-width for the columns, but then some cells have a bigger lenght the columns are getting messy anyway.
In fact this min-width usage is on the official exaple docs
https://www.primefaces.org/primereact/datatable/scroll/
Another problem is that if the table has a large number of columns, min-width will cause unused empty spaces that cannot be abused.
Please don't drop priority over this issue🙏. It will be a big score for the next release 🚀

@melloware
Copy link
Member

I don't work for PrimeTek.

I assigned it to Mert who is in charge of this project for PrimeTek.

@ubau
Copy link

ubau commented Jul 23, 2022

Well, this is just a workaround and issue still remains.
Speaking about unused empty spaces you can use different min width for every column.
If the cell content is biger than column width there are two options - you can wrap content or use:
className="white-space-nowrap overflow-hidden text-overflow-ellipsis" (set max width also) and show full content in Tooltip.
Actually I don't use scrollable anymore, it's enough with responsiveLayout="scroll".

@melloware
Copy link
Member

Looks like this is a duplicate this person had the same issues and I commented with solutions and screenshots: #2951

@melloware
Copy link
Member

I think this ticket is also related: #2479 @ubau

@Dav3rs
Copy link
Author

Dav3rs commented Jul 23, 2022

If this styles are removed from the row

image

This from the header

image

And this styles are removed from the cells

image

The bug is completely and beautifully gone.

It can be localy fixed by overwriting the styles with

.p-datatable-scrollable .p-datatable-thead > tr,
.p-datatable-scrollable .p-datatable-tbody > tr,
.p-datatable-scrollable .p-datatable-tfoot > tr {
	display: table-row !important;
}
.p-datatable-scrollable .p-datatable-thead > tr > th,
.p-datatable-scrollable .p-datatable-tbody > tr > td,
.p-datatable-scrollable .p-datatable-tfoot > tr > td {
	display: table-cell !important;
}

.p-datatable-scrollable .p-datatable-thead,
.p-datatable-scrollable .p-datatable-tbody,
.p-datatable-scrollable .p-datatable-tfoot {
	display: table-header-group !important;
}

I confirm, the bug is gone.

@mertsincan
Copy link
Member

Thanks a lot, @Dav3rs! We changed datatable's structure. I think this issue has already been fixed in 9.2.0. Please try it.
#4078

Best Regards,

@mertsincan mertsincan removed Type: Bug Issue contains a defect related to a specific component. Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team labels Feb 22, 2023
@mertsincan mertsincan removed this from the 10.0.0 milestone Feb 22, 2023
@mertsincan mertsincan removed their assignment Feb 22, 2023
@melloware
Copy link
Member

Confirmed this is fixed in 9.2.0

@melloware melloware added this to the 9.2.0 milestone Feb 22, 2023
@mertsincan mertsincan removed this from the 9.2.0 milestone Mar 2, 2023
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

5 participants