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: resizableColumns with stateStorage will not adjust saved column width after refresh. #4211

Closed
netcan opened this issue Apr 2, 2023 · 3 comments · Fixed by #4415
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@netcan
Copy link

netcan commented Apr 2, 2023

Describe the bug

I use stateStorage to save DataTable state, which includes column width/column order etc. if I refresh the page, the column width is reset, it should keep the width before the refresh.

Reproducer

https://codesandbox.io/embed/primereact-demo-forked-khph5t?fontsize=14&hidenavigation=1&theme=dark

PrimeReact version

9.2.2

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome 111.0.5563.146

Steps to reproduce the behavior

Goto reproducer, adjust the column width and refresh the page.

Expected behavior

after refreshing the page, the column width remains as before.

@netcan netcan added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 2, 2023
@netcan netcan changed the title resizableColumns with stateStorage will not adjust saved column width after refresh. DataTable: resizableColumns with stateStorage will not adjust saved column width after refresh. Apr 2, 2023
@netcan
Copy link
Author

netcan commented Apr 2, 2023

the code here set the attributeSelectorState:

!attributeSelectorState && setAttributeSelectorState(UniqueComponentId());

but recover the column width using attributeSelectorState is null:

let selector = `.p-datatable[${attributeSelectorState}] > .p-datatable-wrapper ${isVirtualScrollerDisabled() ? '' : '> .p-virtualscroller'} > .p-datatable-table`;

@melloware
Copy link
Member

@netcan do you have a proposed fix?

melloware added a commit to melloware/primereact that referenced this issue May 17, 2023
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels May 17, 2023
@melloware melloware self-assigned this May 17, 2023
@melloware melloware added this to the 9.5.0 milestone May 17, 2023
@melloware
Copy link
Member

Submitted a PR. it should not have been using a State variable but a ref as setAttributeSelector(xx) is still not in the immediate call afterwards.

melloware added a commit to melloware/primereact that referenced this issue May 17, 2023
melloware added a commit to melloware/primereact that referenced this issue May 17, 2023
melloware added a commit that referenced this issue May 17, 2023
* Fix #4211: Datatable attribute selector use Ref not state

* Fix #4211: Datatable attribute selector use Ref not state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants