diff --git a/packages/utilities/src/a11y/TrapFocus.ts b/packages/utilities/src/a11y/TrapFocus.ts index b1e9023f..277685d6 100644 --- a/packages/utilities/src/a11y/TrapFocus.ts +++ b/packages/utilities/src/a11y/TrapFocus.ts @@ -144,6 +144,10 @@ class TrapFocus { // Focus stayed inside the wrapper, no need to refocus if (this.#root.contains(currentActiveElement)) return; + // Focus was intentionally moved to another component (e.g. a portal opened from inside the trap). + // Only refocus when focus was dropped (fell back to body), not when another component took it. + if (document.activeElement && document.activeElement !== document.body) return; + const focusable = getFocusableElements(this.#root, { additionalElement: includeTrigger ? trigger : undefined, });