From fced6e655416d9386c23d510caf627180059c747 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 10 Oct 2022 09:30:25 -0400 Subject: [PATCH] Fix crash when opening pod details (#6376) Signed-off-by: Sebastian Malton Signed-off-by: Sebastian Malton --- src/renderer/components/menu/menu.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/renderer/components/menu/menu.tsx b/src/renderer/components/menu/menu.tsx index b43f3a497b..87adbd839e 100644 --- a/src/renderer/components/menu/menu.tsx +++ b/src/renderer/components/menu/menu.tsx @@ -79,10 +79,10 @@ class NonInjectedMenu extends React.Component { super(props); autoBind(this); } - public opener: HTMLElement | null = null; - public elem: HTMLUListElement | null = null; + private opener: HTMLElement | null = null; + private elem: HTMLUListElement | null = null; protected items: { [index: number]: MenuItem } = {}; - public state: State = {}; + state: State = {}; get isOpen() { return !!this.props.isOpen; @@ -98,15 +98,15 @@ class NonInjectedMenu extends React.Component { htmlFor, toggleEvent, } = this.props; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const elem = this.elem!; if (!usePortal) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const parent = elem.parentElement!; - const position = window.getComputedStyle(parent).position; + if (this.elem?.parentElement) { + const { position } = window.getComputedStyle(this.elem.parentElement); - if (position === "static") parent.style.position = "relative"; + if (position === "static") { + this.elem.parentElement.style.position = "relative"; + } + } } else if (this.isOpen) { this.refreshPosition(); }