Skip to content

Router: Destroy route component when disconnected (Fixes #21272)#21318

Merged
nielslyngsoe merged 5 commits intomainfrom
v17/bugfix/21272-destroy-workspaces-when-disconnection-dom
Jan 19, 2026
Merged

Router: Destroy route component when disconnected (Fixes #21272)#21318
nielslyngsoe merged 5 commits intomainfrom
v17/bugfix/21272-destroy-workspaces-when-disconnection-dom

Conversation

@nielslyngsoe
Copy link
Member

Fixes #21272

Test Notes:

Notice this will destroy a route component when the router element is disconnected. Is there any case where we like to reuse an element despite the router being removed? Or is there a case where a router gets disconnected and reconnected, so the destroy would result in breaking the content of the router?

@nielslyngsoe nielslyngsoe marked this pull request as ready for review January 8, 2026 14:16
Copilot AI review requested due to automatic review settings January 8, 2026 14:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #21272 by ensuring route components are properly destroyed when a router element is disconnected from the DOM. The changes add cleanup logic to prevent memory leaks and ensure proper lifecycle management of routed components.

Key changes:

  • Added cleanup in router-slot's disconnectedCallback to clear children and reset route match state
  • Applied umbDestroyOnDisconnect directive to workspace elements in modals to ensure proper destruction

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Umbraco.Web.UI.Client/src/packages/core/router/router-slot/router-slot.ts Adds clearChildren() and _routeMatch = null to disconnectedCallback to properly destroy child route components when router is disconnected
src/Umbraco.Web.UI.Client/src/packages/core/workspace/modals/workspace-modal.element.ts Applies umbDestroyOnDisconnect() directive to workspace elements to ensure proper cleanup when modal is closed

@nielslyngsoe nielslyngsoe enabled auto-merge (squash) January 16, 2026 14:50
@nielslyngsoe nielslyngsoe merged commit 7acdc6e into main Jan 19, 2026
28 checks passed
@nielslyngsoe nielslyngsoe deleted the v17/bugfix/21272-destroy-workspaces-when-disconnection-dom branch January 19, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace context destroy() not called when navigating between sections

2 participants