Fix crash when opening pod details (#6376)

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-10-10 09:30:25 -04:00
1 parent a7ea891458
commit fced6e6554
1 file changed
+9 -9
+9 -9
View File
@@ -79,10 +79,10 @@ class NonInjectedMenu extends React.Component<MenuProps & Dependencies, State> {
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<MenuProps & Dependencies, State> {
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();
}