Draggable - Add safety guards for Angular SSR and disposal#33775
Merged
aleksei-semikozov merged 1 commit intoJun 1, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves robustness around Draggable/Sortable disposal and Angular server-side rendering by adding defensive guards to prevent runtime crashes in edge cases (uninitialized animator, empty/non-element SSR output).
Changes:
- Make Draggable’s
_stopAnimatortolerant to an uninitialized_scrollAnimator. - Add a Jest test ensuring
dxSortable.dispose()doesn’t throw when_scrollAnimatoris missing. - Add a guard in Angular SSR rendering to avoid dereferencing a missing rendered root node.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
packages/devextreme/js/__internal/m_draggable.ts |
Makes animator stopping safe when _scrollAnimator is missing. |
packages/devextreme/js/__internal/__tests__/draggable_dispose.test.ts |
Adds a regression test for safe disposal when _scrollAnimator is undefined. |
packages/devextreme-angular/src/server/render.ts |
Adds SSR guard to avoid crashes when the rendered markup has no root node. |
Comment on lines
27
to
31
| const mainElement = temp.childNodes[0]; | ||
| if (!mainElement) { | ||
| return; | ||
| } | ||
| const childString = mainElement.innerHTML; |
Comment on lines
+1
to
+7
| import $ from '@js/core/renderer'; | ||
| import Sortable from '@js/ui/sortable'; | ||
|
|
||
| describe('Draggable dispose safety', () => { | ||
| beforeEach(() => { | ||
| document.body.innerHTML = ''; | ||
| }); |
Comment on lines
+9
to
+12
| it('should not crash on _stopAnimator when _scrollAnimator is not initialized', () => { | ||
| const $container = $('<div>').appendTo(document.body); | ||
| const sortable = new Sortable($container, {}); | ||
|
|
GoodDayForSurf
approved these changes
Jun 1, 2026
Alyar666
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.