We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent acbfc87 commit 897233eCopy full SHA for 897233e
packages/core/primitive/src/primitive.tsx
@@ -78,10 +78,17 @@ export function isFrame(element: Element): element is HTMLIFrameElement {
78
* Utility to get the currently focused element even across Shadow DOM boundaries
79
*/
80
export function getDeepActiveElement(): Element | null {
81
+ if (!canUseDOM) {
82
+ return null;
83
+ }
84
+
85
let activeElement = document.activeElement;
86
+ if (!activeElement) {
87
88
89
90
// Traverse through shadow DOMs to find the deepest active element
- while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) {
91
+ while (activeElement.shadowRoot?.activeElement) {
92
activeElement = activeElement.shadowRoot.activeElement;
93
}
94
0 commit comments