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

Table: Resizable columns in expand mode with state feature. Column sizes not properly restored #12398

Closed
An0d opened this issue Dec 19, 2022 · 0 comments · Fixed by #12399
Closed
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@An0d
Copy link
Contributor

An0d commented Dec 19, 2022

Describe the bug

When using the resizable columns in "expand" mode with the state feature.
The size of the columns is not correctly restored.

The total width of the table is saved in the state with the format "1234px".
When restoring the state of the columns, the method "restoreColumnWidths" restores the total width of the table by adding "px" again (it tries to restore the width with the value "1234pxpx")

saveColumnWidths(state) {
...
        if (this.columnResizeMode === 'expand') {
            state.tableWidth = DomHandler.getOuterWidth(this.tableViewChild.nativeElement) + 'px';
        }
...
}

restoreColumnWidths() {
...
        if (this.columnResizeMode === 'expand' && this.tableWidthState) {
            this.setResizeTableWidth(this.tableWidthState + 'px');
        }
...
}

Environment

PrimeNG 14.x
Table component with Resizable columns & expand mode & table state feature

Reproducer

https://stackblitz.com/edit/github-3ah8na

Angular version

14

PrimeNG version

14

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18

Browser(s)

No response

Steps to reproduce the behavior

  1. Go to https://stackblitz.com/edit/github-3ah8na
  2. Resize a column
    State is saved in local storage under https://github-3ah8na.stackblitz.io > statedemo-local
  3. Refresh the sample
  4. Column size is not properly restored
  5. Edit statedemo-local stored in local storage
    Remove "px" from tableWidth
  6. Refresh the sample
  7. Column size is now properly restored

Expected behavior

Column sizes should be restored when using expand mode with state feature

@An0d An0d added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 19, 2022
@An0d An0d mentioned this issue Dec 19, 2022
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 20, 2022
@cetincakiroglu cetincakiroglu added this to the 15.0.1 milestone Dec 20, 2022
cetincakiroglu added a commit that referenced this issue Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants