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

TypeError: Cannot read properties of undefined (reading 'classList') at Function.addClass #10909

Closed
LorenzSLA opened this issue Dec 2, 2021 · 5 comments
Assignees
Labels
LTS-FIXED-12.2.4 Fixed in PrimeNG LTS 12.2.4 Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@LorenzSLA
Copy link
Contributor

Hello everybody,

I'm submitting a ...

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
https://github.com/LorenzSchl/primeng-classlist-null-example
For some reason the error does not show in stackblitz. For me it only "works" or better fails with ng serve and chrome.

Current behavior
The following error is thrown:

core.js:6498 ERROR TypeError: Cannot read properties of null (reading 'classList')
    at Function.addClass (primeng-dom.js:12)
    at Dialog.onAnimationStart (primeng-dialog.js:477)
    at Dialog_div_0_div_1_Template_div_animation_animation_start_0_listener (primeng-dialog.js:542)
    at executeListenerWithErrorHandling (core.js:15327)
    at wrapListenerIn_markDirtyAndPreventDefault (core.js:15365)
    at animations.js:198
    at Array.forEach (<anonymous>)
    at animations.js:196
    at ZoneDelegate.invoke (zone.js:372)
    at Object.onInvoke (core.js:28692)

Expected behavior
No error to be thrown.

Minimal reproduction of the problem with instructions
Hard to repoduce. If the dialog is openend, closed, repoened while closing animation is still running (after onAnimationStart and before onAnimationEnd) and closed after the onAnimationEnd. The wrapper will already have been nulled but the onAnimationStart(fromStage: visible, toStage: void) will try to add a class to the wrapper.

What is the motivation / use case for changing the behavior?
The bug was introduced in the following commit: 5365533

Please tell us about your environment:
Windows 10 Version 1909 (Build 18363.1916), IntelliJ IDEA 2021.2, NPM 8.1.0

  • Angular version: 12.2.13
  • PrimeNG version: 12.2.2
  • Browser: [Chrome 96.0.4664.45]
  • Language: [TypeScript 4.3.5]
  • Node (for AoT issues): node --version = v16.13.0
@ludopak
Copy link

ludopak commented Dec 2, 2021

@LorenzSLA I added a comment to your fix, I think the same fix should be done in dialog.ts file.
What do you think?

LorenzSLA added a commit to LorenzSLA/primeng that referenced this issue Dec 2, 2021
Added nullcheck before accessing property to avoid error described in: primefaces#10909
@LorenzSLA
Copy link
Contributor Author

@LorenzSLA I added a comment to your fix, I think the same fix should be done in dialog.ts file. What do you think?

I updated the PR. Thanks :)

@yigitfindikli yigitfindikli self-assigned this Dec 2, 2021
@yigitfindikli yigitfindikli added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Dec 2, 2021
@yigitfindikli yigitfindikli added this to the 13.0.2 milestone Dec 2, 2021
@ludopak
Copy link

ludopak commented Dec 2, 2021

@yigitfindikli Will this kind of fixes be included in previous release? 12.2.4 for example?
I ask to know if we need to find a solution to fix it in another way in our application :)

@LorenzSLA
Copy link
Contributor Author

@yigitfindikli Will this kind of fixes be included in previous release? 12.2.4 for example? I ask to know if we need to find a solution to fix it in another way in our application :)

Until the fix is added to PrimeNG and we were able to update, we added the following option to work around the issue:

[transitionOptions]="'0ms'"

@yigitfindikli yigitfindikli added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working LTS-PORTABLE and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Dec 3, 2021
@yigitfindikli
Copy link
Contributor

Hi @ludopak am=nd @LorenzSLA,

V12 community support is over. But will be added to v12-lts.

Regards.

@yigitfindikli yigitfindikli added LTS-FIXED-12.2.4 Fixed in PrimeNG LTS 12.2.4 and removed LTS-PORTABLE labels Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-FIXED-12.2.4 Fixed in PrimeNG LTS 12.2.4 Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants