Skip to content

Core: Minimize await to a single JS cycle (refactor #21186)#22074

Merged
nielslyngsoe merged 10 commits intomainfrom
v17/improvement/refactor-21186-with-one-js-cycle
Mar 10, 2026
Merged

Core: Minimize await to a single JS cycle (refactor #21186)#22074
nielslyngsoe merged 10 commits intomainfrom
v17/improvement/refactor-21186-with-one-js-cycle

Conversation

@nielslyngsoe
Copy link
Copy Markdown
Member

Minimize the disconnect-debounce to use a single JS cycle instead of a whole rendering frame.

Refactor / continued work of #21186

Copilot AI review requested due to automatic review settings March 10, 2026 13:31
@nielslyngsoe nielslyngsoe enabled auto-merge (squash) March 10, 2026 13:32
Copy link
Copy Markdown
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

Refactors several disconnect/deferred-destruction paths to avoid waiting a full rendering frame, using a single JS-cycle (microtask) cancellation pattern instead. This supports the extension slot lifecycle behavior needed during DOM moves/sorting (continuation of #21186).

Changes:

  • Replaced requestAnimationFrame-based disconnect debouncing with a microtask (Promise.resolve().then(...)) + AbortController cancellation in multiple components.
  • Updated extension slot elements to cancel pending teardown on reconnect using the new AbortController pattern.
  • Refactored UmbContextConsumer disconnect handling and “listening scope” management to align with the new single-cycle behavior.

Reviewed changes

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

File Description
src/Umbraco.Web.UI.Client/src/packages/core/lit-element/directives/destroy.lit-directive.ts Switches directive teardown deferral from rAF to microtask + AbortController.
src/Umbraco.Web.UI.Client/src/packages/core/extension-registry/components/extension-with-api-slot/extension-with-api-slot.element.ts Updates deferred controller destruction to microtask + AbortController cancellation.
src/Umbraco.Web.UI.Client/src/packages/core/extension-registry/components/extension-slot/extension-slot.element.ts Updates deferred destruction/event listener cleanup to microtask + AbortController cancellation.
src/Umbraco.Web.UI.Client/src/libs/context-api/consume/context-consumer.ts Refactors disconnect cancellation and current “scope” event listening to avoid rAF usage.

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.

3 participants