1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

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 2022-10-10 09:30:25 -04:00 committed by GitHub
parent a7ea891458
commit fced6e6554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,10 +79,10 @@ class NonInjectedMenu extends React.Component<MenuProps & Dependencies, State> {
super(props); super(props);
autoBind(this); autoBind(this);
} }
public opener: HTMLElement | null = null; private opener: HTMLElement | null = null;
public elem: HTMLUListElement | null = null; private elem: HTMLUListElement | null = null;
protected items: { [index: number]: MenuItem } = {}; protected items: { [index: number]: MenuItem } = {};
public state: State = {}; state: State = {};
get isOpen() { get isOpen() {
return !!this.props.isOpen; return !!this.props.isOpen;
@ -98,15 +98,15 @@ class NonInjectedMenu extends React.Component<MenuProps & Dependencies, State> {
htmlFor, htmlFor,
toggleEvent, toggleEvent,
} = this.props; } = this.props;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const elem = this.elem!;
if (!usePortal) { if (!usePortal) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion if (this.elem?.parentElement) {
const parent = elem.parentElement!; const { position } = window.getComputedStyle(this.elem.parentElement);
const position = window.getComputedStyle(parent).position;
if (position === "static") parent.style.position = "relative"; if (position === "static") {
this.elem.parentElement.style.position = "relative";
}
}
} else if (this.isOpen) { } else if (this.isOpen) {
this.refreshPosition(); this.refreshPosition();
} }