question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

trackBy is broken in version 9.3

See original GitHub issue

Hello.

I’m using gridster as a dashboard creating tool, so items dynamically change (they can be added or removed on demand). To prevent refreshing item views too many times, I’m using my own trackBy function. Up to 9.2 version everything was working as it should, but now i get the following errors when adding and removing the same item in the same “session” (without reloading page / gridster in between):

vpsc.ts:554 ERROR TypeError: Cannot read property 'gridRenderer' of undefined at GridsterItemComponent.push../node_modules/angular-gridster2/__ivy_ngcc__/fesm5/angular-gridster2.js.GridsterItemComponent.setSize (vpsc.ts:554) at GridsterComponent.push../node_modules/angular-gridster2/__ivy_ngcc__/fesm5/angular-gridster2.js.GridsterComponent.calculateLayout (vpsc.ts:554) at later (vpsc.ts:554) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:3504) at Object.onInvokeTask (vpsc.ts:554) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:3503) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (polyfills.js:3271) at push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask (polyfills.js:3586) at ZoneTask.invoke (polyfills.js:3575) at timer (polyfills.js:6117)

I tried to change my trackBy function to only track by index and the problem remains.

I saw that some additional trackBy functionalities were added in 9.3. Would it be possible, to add option to disable them on demand?

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tiberiuzuldcommented, Aug 3, 2020

Fixed in v10.1.3 Thank you for reporting the issue and reproducing in stackblits @tmtron and @robleka

1reaction
tmtroncommented, Aug 2, 2020

I think I hit the same problem.

IMHO: adding a timeout is not a solution - not even a workaround, because then it may sometimes work and sometimes fail: e.g. when the CPU is busy or on slow mobile devices, etc.

Here is a Stackblitz example to reproduce the issue.

Notes:

  • the example uses the default change detection strategy (not OnPush)
  • the reset feature uses the workaround as explained in #644

Reproduction steps:

  • click on the ID: 0 text to remove the item
  • click reset
  • click on the ID: 0 again
  • check the errors in the console (at the bottom of the stackblitz browser section

It seems that the error occurs in the setSize function as outlined in the comment above.

This maybe be possible if the calculateLayout was deferred and the item was removed while doing that.

In this case, maybe the calculateLayout function can first check if this item has already been destroyed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular ngFor trackBy not working. Not Updating DOM
Hi y'all my dom is not being updated with trackBy for some reason. I have another component where trackBy is working great but...
Read more >
Change Log | NG-ZORRO - Ant Design
Major version release is not included in this schedule for breaking ... transfer: add trackBy to the list and track by the hide...
Read more >
MagicQ Software Change Log - ChamSys
Fix for setting times without values broken in versions 1.9.1.0 and above ( e.g. 1 @ / 5 and 1 @ / 2...
Read more >
May 27 - Facebook
Love those missiles that track by themselves while the rest get's nothing to counter ... As long the matchmaking BR stay broken i...
Read more >
THE NAVAL AVIATION MAINTENANCE PROGRAM (NAMP)
Upon release of the message, a copy will be e-mailed to ... authorization to perform repairs damaged beyond allowable repair limits.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found