Destroy can be called before primary button is created. [Undefined Error]

Whats the exception?

ERROR TypeError: Cannot read property 'destroy' of undefined
    at SplitButtonComponent.SplitButton.destroy (ej2-splitbuttons.es5.js:721)
    at SplitButtonComponent.ComponentBase.ngOnDestroy (ej2-ng-base.es5.js:239)
    at callProviderLifecycles (core.js:12746)

How to recreate the exception?

Create any scenario where splitbuttons may be created and destroyed very quickly. Infinite scroll components are perfect candidates and where I ran into the issue.



3 Replies

SP Sangeetha Priya Murugan Syncfusion Team April 18, 2018 03:17 AM UTC

Hi Eric Solari, 
 
Thank you for using Syncfusion products. 
 
We have checked your reported issue by creating an Angular sample. The sample contains two tabs and each tab contains EJ2 SplitButton components. While switching the tabs frequently, we can reproduce the reported issue in our end as like in the below screenshot. Could you please check it and confirm us whether you’re facing the same in your end? 
 
 
Screenshot
 
 
Also, we would like to know more information about “Infinite scroll components are suitable candidates” that you have mentioned. So, that we could able to sort out the cause of this issue based on your exact scenario and provide you a better solution quickly? The information provided would be great help for us to proceed further. 
 
Regards, 
Sangeetha Priya M 



ES Eric Solari April 18, 2018 02:14 PM UTC

I checked your sample and that appears to be the same issue. I came across this issue using the split button within a cell template of ag-grid. It has an infinite scroll / virtual scroll feature that destorys and re-renders rows as you scroll. Because you can scroll quickly you end up creating / destroying split buttons very quickly. I tried manually destroying the splitbuttons by calling the .destroy() method during row tear down but it just pushed the undefined error to the secondaryButton. 


SM Saranya Murugasamy Syncfusion Team April 19, 2018 09:47 AM UTC

Hi Eric, 

We have confirmed this as a defect & logged a defect report for “Script error throws on component destroy at continuous routing”. This fix will be available in our patch release by May 2, 2018 release. We will update you once the fix for the issue is available until then we appreciate your patience.   
  
Please let us know if you have any concerns. 
 
Regards, 
Saranya Murugasamy 


Loader.
Up arrow icon