Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent toolbar from stealing focus when focus has already been …
…moved (#6934) * fix: prevent toolbar from stealing focus when focus has already been moved in the document * Change files --------- Co-authored-by: Christopher Holt <=>
- Loading branch information
1 parent
0c27d02
commit 7f8e2db
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-foundation-452bb1d9-58ef-4cb0-a6fa-0ed41d1ad057.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "fix: prevent toolbar from stealing focus when focus has already been moved in the document", | ||
"packageName": "@microsoft/fast-foundation", | ||
"email": "=", | ||
"dependentChangeType": "patch" | ||
} |
This file contains 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
10 changes: 10 additions & 0 deletions
10
packages/web-components/fast-foundation/src/utilities/root-active-element.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// returns the active element in the shadow context of the element in question. | ||
export function getRootActiveElement(element: Element): Element | null { | ||
const rootNode = element.getRootNode(); | ||
|
||
if (rootNode instanceof ShadowRoot) { | ||
return rootNode.activeElement; | ||
} | ||
|
||
return document.activeElement; | ||
} |