Skip to content

CreateFocusScopeManager

Methods

activateScope

Source code

createFocusScopeManager~activateScope(scope, focusSource)

Activates a specific scope.

ParamTypeDescription
scopeobjectThe scope to activate.
focusSource'unknown'
'click'
'tab_from_above'
'tab_from_below'
The source of the focus event.

deactivateScope

Source code

createFocusScopeManager~deactivateScope(scope, [restoreShortcutsContext])

Deactivates a scope.

ParamTypeDefaultDescription
scopeobjectThe scope to deactivate.
[restoreShortcutsContext]booleantrueoptional Whether to roll the shortcuts context back to the one the scope displaced. False when a focus event moved the user, which means only “the user is elsewhere now” - the displaced name is KEPT there, so a later explicit deactivation can still use it.

hasOtherScopeWithSameFallback

Source code

createFocusScopeManager~hasOtherScopeWithSameFallback(scopeToSkip) ⇒ boolean

Whether a scope other than the one given still declares the same context/fallback pair.

The fallback lives on the shortcuts CONTEXT, which several scopes may share, so unregistering one of them must not drop a fallback the others still rely on.

ParamTypeDescription
scopeToSkipobjectThe scope being unregistered.

processScopes

Source code

createFocusScopeManager~processScopes(target, focusSource)

Activates or deactivates the appropriate scope based on the target element that was triggered by the focus or click event.

ParamTypeDescription
targetHTMLElementThe target element.
focusSource'unknown'
'click'
'tab_from_above'
'tab_from_below'
The source of the focus event.

restoreDisplacedShortcutsContext

Source code

createFocusScopeManager~restoreDisplacedShortcutsContext(scope)

Rolls the shortcuts context back to whatever the scope displaced when it was activated.

Deactivation used to leave the context alone, so nothing but a later focus or click event reaching processScopes() ever rolled it back. Undoing a full row removal from the context menu fires neither, so the grid came back full of data, looking completely normal, with every shortcut dead until the user clicked a cell (DEV-2917).

Only an EXPLICIT deactivateScope() restores. A deactivation driven by a focus event leaves the context alone, because a scope may stand aside while the user is still working inside it: the sheets bar disables its own scope while its menu is open (runOnlyIf: () => !menus.isOpened()) precisely so that activating it would not hand the keyboard back to the grid, and rolling the context back there broke every keyboard command in that menu. The stale name that leaves behind is handled where it is created - activateScope() never records a scope’s own context as the one it displaced.

ParamTypeDescription
scopeobjectThe scope being deactivated.

scopeContains

Source code

createFocusScopeManager~scopeContains(scope, target) ⇒ boolean

Checks whether the scope contains the target element, looking through the shadow boundaries the target is rendered behind.

A scope answers containment with Node.contains(), which stops at a shadow root, so a target resolved from inside a shadow tree the scope’s container merely hosts (a web component rendered in a cell) is reported as outside it. Falling back to the target’s shadow hosts asks the same question about the elements the container can actually see.

ParamTypeDescription
scopeobjectThe focus scope to ask.
targetElement
null
The target element. getDeepActiveElement() reports null for a document with no body, and no scope contains a target that is not an element to begin with.

Returns: boolean - true when the target, or one of the hosts it is rendered behind, is within the scope.

updateScopesFocusVisibilityState

Source code

createFocusScopeManager~updateScopesFocusVisibilityState()

Updates the focus scopes state by enabling or disabling them or their focus catchers to make sure that the next native focus move won’t be disturbed.