Skip to content

Commit 3330f01

Browse files
authored
fix: patchPopup now assumes that content may be null (#9950)
1 parent 8676841 commit 3330f01

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/base/src/features/patchPopup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type OpenUI5Popup = {
99
open: (...args: any[]) => void,
1010
_closed: (...args: any[]) => void,
1111
getOpenState: () => "CLOSED" | "CLOSING" | "OPEN" | "OPENING",
12-
getContent: () => Control | HTMLElement, // this is the OpenUI5 Element/Control instance that opens the Popup (usually sap.m.Popover/sap.m.Dialog)
12+
getContent: () => Control | HTMLElement | null, // this is the OpenUI5 Element/Control instance that opens the Popup (usually sap.m.Popover/sap.m.Dialog)
1313
onFocusEvent: (e: FocusEvent) => void,
1414
}
1515
};
@@ -35,7 +35,7 @@ const patchOpen = (Popup: OpenUI5Popup) => {
3535
if (openingInitiated && topLayerAlreadyInUse) {
3636
const element = this.getContent();
3737
if (element) {
38-
const domRef = element instanceof HTMLElement ? element : element.getDomRef();
38+
const domRef = element instanceof HTMLElement ? element : element?.getDomRef();
3939
if (domRef) {
4040
openNativePopover(domRef);
4141
}
@@ -48,7 +48,7 @@ const patchClosed = (Popup: OpenUI5Popup) => {
4848
const _origClosed = Popup.prototype._closed;
4949
Popup.prototype._closed = function _closed(...args: any[]) {
5050
const element = this.getContent();
51-
const domRef = element instanceof HTMLElement ? element : element.getDomRef();
51+
const domRef = element instanceof HTMLElement ? element : element?.getDomRef();
5252
_origClosed.apply(this, args); // only then call _close
5353
if (domRef) {
5454
closeNativePopover(domRef); // unset the popover attribute and close the native popover, but only if still in DOM

0 commit comments

Comments
 (0)