Skip to content

Commit 904da0e

Browse files
authored
fix(ui5-popover): fix js errors if parent is removed from DOM (#2178)
1 parent 31ca287 commit 904da0e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/main/src/popup-utils/PopupUtils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let currentZIndex = 100;
33
const getFocusedElement = () => {
44
let element = document.activeElement;
55

6-
while (element.shadowRoot && element.shadowRoot.activeElement) {
6+
while (element && element.shadowRoot && element.shadowRoot.activeElement) {
77
element = element.shadowRoot.activeElement;
88
}
99

@@ -62,7 +62,7 @@ const isClickInRect = (event, rect) => {
6262
const getClosedPopupParent = el => {
6363
const parent = el.parentElement || (el.getRootNode && el.getRootNode().host);
6464

65-
if ((parent.openBy && parent.isUI5Element) || (parent.open && parent.isUI5Element) || parent === document.documentElement) {
65+
if (parent && ((parent.openBy && parent.isUI5Element) || (parent.open && parent.isUI5Element) || parent === document.documentElement)) {
6666
return parent;
6767
}
6868

0 commit comments

Comments
 (0)