TypeError: Cannot read properties of undefined (reading 'nativeElement') with scrollable and state enabled table #10792
Labels
LTS-PORTABLE
Issue's fix will be ported to supported LTS versions
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
I'm submitting a ...
Plunkr Case (Bug Reports)
I was unable to reproduce this issue with StackBlitz. I have code below to reproduce the issue in Chrome.
Current behavior
I added a table to my application that has sortable columns, is scrollable and persists state to
localStorage
. After a sort is set in state by clicking one of the table column headers, I start to see the error below when I refresh the browser to reload the application, or the application reloads after a rebuild when usingng serve
.If I remove the
scrollable
andscrollHeight
attributes, no error is thrown. If I remove thestateKey
andstateStorage
attributes, no error is thrown. If I have all 4 of these attributes on the table, the error is thrown. If I clear the state fromlocalStorage
, the error stops getting thrown until I sort the table again.Expected behavior
I would not get any console error when loading the application. These attributes should work together without throwing an error.
Minimal reproduction of the problem with instructions
Create a new angular application using the CLI, install primeng, primeicons, and primeflex.
Create a new component named case-list, code below.
case-list.component.ts
case-list.component.html
Add the component to the app.component.html.
app.component.html
Run the application using
ng serve
.Click a column header to set a sort, any column will do. Press F12 to open the Chrome dev tools, and then reload the application using the F5 key. You should see the error above in the console.
Environment:
Angular version: 12.2.4
PrimeNG version: 12.2.1
Browser: Chrome 95
Language: TypeScript 4.3.5
Node (for AoT issues): 14.17.3
Repo: https://github.com/rdrrichards/prime-table
The text was updated successfully, but these errors were encountered: