@progress/kendo-angular-grid: 26.0.0@progress/kendo-angular-toolbar: 26.0.0Destroying a grid and its environment injector before the next timer turn causes an uncaught NG0205: Injector has already been destroyed error when the grid contains a kendo-toolbar-button with kendoGridAddTool and no explicit text.
The original occurrence is in Angular unit tests with normal teardown: {destroyAfterEach: true}. Synchronous component tests create/render the grid and finish before the toolbar's text-initialization timer runs. Jasmine reports the escaped asynchronous error as "An error was thrown in afterAll".
The attached standalone reproduction requires neither Karma nor Jasmine.
Import the attached project into StackBlitz, or use the accompanying HTML launcher. Save/fork the resulting StackBlitz and include its URL with this report.
npm install, then npm start locally).text.Relevant template:
<kendo-grid [data]="[]">
<kendo-toolbar>
<kendo-toolbar-button kendoGridAddTool />
</kendo-toolbar>
</kendo-grid>
The control adds text="Add" to the same button. No other lifecycle behavior changes. The reproduction explicitly destroys the environment injector to model the original TestBed teardown; it does not claim that every ordinary component removal destroys the application injector.
Destroying the grid and its injector should cancel or safely ignore pending initialization work. No callback should mutate a destroyed toolbar button or try to register a render callback with a destroyed injector.
An uncaught asynchronous error is thrown:
Error: NG0205: Injector has already been destroyed. at assertNotDestroyed at R3Injector.get at ChainedInjector.get at lookupTokenUsingModuleInjector at getOrCreateInjectable at NodeInjector.get at afterEveryRenderImpl at afterNextRender at ToolBarButtonComponent.setTextDisplayMode at set text
In the distributed 26.0.0 packages:
@progress/kendo-angular-grid/fesm2022/progress-kendo-angular-grid.mjsToolbarToolBase.ngAfterViewInit (around lines 14576-14590) schedules a setTimeout outside Angular when the host button has no text.this.host.text.ToolbarToolBase.ngOnDestroy only unsubscribes its click subscription; it does not cancel the timeout or guard its callback against destruction.@progress/kendo-angular-toolbar/fesm2022/progress-kendo-angular-toolbar.mjstext setter (around line 2840) calls setTextDisplayMode.setTextDisplayMode (around line 3162) registers afterNextRender with the button's injector. This fails if that injector has already been destroyed.The original application uses the same base behavior through Add, Save, and Cancel toolbar tools. The standalone reproduction needs only the Add tool.
Tie the pending text-initialization timeout to the directive lifetime: cancel it on destruction and/or prevent its callback from updating a destroyed host. Retain the normal localized default text behavior for live components.
Please add a regression test covering destruction of both the grid fixture and its environment injector before the pending timeout executes.
https://stackblitz.com/edit/stackblitz-starters-pa5nsfho
The attached minimal project was built successfully and run in headless Chrome. Automated browser checks confirmed:
afterNextRender, setTextDisplayMode, and the text setter in the stack.