primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
10.46k stars 4.6k forks source link

v16.7.0: p-table column length issue #14000

Open eXpertise7 opened 1 year ago

eXpertise7 commented 1 year ago

Describe the bug

At PrimeNG 16.7.0 version, dynamic columns at p-table do not appear, and length issue at browser console appears.

On PrimeNG 16.6.0 version and versions below, issue does not appear.

image

I can create stackblitz example, if needed, but this is real bug that's introduced in primeng migration from v16.6.0 to v16.7.0. Developers who have dynamic columns at tables are going to notice this immediately, because everything will break.

@cetincakiroglu please take a look at this. Thanks.

Environment

Angular v16.2.3, PrimeNG v16.7.0.

Reproducer

No response

Angular version

16.2.3

PrimeNG version

16.7.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

16.20.2

Browser(s)

Google Chrome, version 118.0.5993.118

Steps to reproduce the behavior

  1. Check the browser's console error in the screenshot.

Expected behavior

Dynamic columns at tables should appear normally, and browser error shouldn't be existing.

eXpertise7 commented 1 year ago

Error message:

error_handler.ts:45 ERROR TypeError: Cannot read properties of null (reading 'length') at UsersListComponent_ng_template_12_Template (users-list.component.html:88:35) at ReactiveLViewConsumer.runInContext (reactive_lview_consumer.ts:48:7) at executeTemplate (shared.ts:266:16) at refreshView (change_detection.ts:140:7) at detectChangesInView (change_detection.ts:320:5) at detectChangesInEmbeddedViews (change_detection.ts:258:7) at refreshView (change_detection.ts:167:5) at detectChangesInView (change_detection.ts:320:5) at detectChangesInEmbeddedViews (change_detection.ts:258:7) at refreshView (change_detection.ts:167:5)

Line 88 in the template is:

<tr [pContextMenuRow]="user" [@tableListAnimation]="columns.length" [pSelectableRow]="user">

This has always worked, the issue is somewhere here.

ZephyrZiggurat commented 1 year ago

Are you using a multiselect to control the default visible columns? They aren't pre-selecting options #13999

cetincakiroglu commented 1 year ago

Hi,

Could you please share a stackblitz example so we can identify the issue?

eXpertise7 commented 1 year ago

Are you using a multiselect to control the default visible columns? They aren't pre-selecting options #13999

We do. Our column data are connected/bound through p-multiSelect and p-table components.

DonnOMalley commented 1 year ago

I found I could reliably cause this bug by using 'resizableColumns' attribute set to 'true'

image

If I omit that attribute or set it to 'false' no error. If I set it to 'true' I get the multiple errors similar to the OP

Check out my stackblitz

eXpertise7 commented 1 year ago

@DonnOMalley well, for years everything has worked fine with resizableColumns set to true, so obviously bug is introduced somewhere with the p-multiselect and p-table bound data.