Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web-components): Use ElementInternals for Radio and RadioGroup components #31783

Merged
merged 14 commits into from
Jul 3, 2024
Merged
Next Next commit
add getRootActiveElement utility function
  • Loading branch information
radium-v committed Jul 3, 2024
commit 4c62603cbae827dd8decdcb326dec3aa9191df94
10 changes: 10 additions & 0 deletions packages/web-components/src/utils/root-active-element.ts
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;
}