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

Fix open/close Menu errors

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-05-17 13:04:18 +03:00
parent 928209f307
commit 5f16b6d36a

View File

@ -8,7 +8,6 @@ import styles from "./styles.module.scss";
import type { HTMLAttributes } from "react";
import React, { useState } from "react";
import { Menu, MenuItem } from "../menu";
import { noop } from "lodash";
import { cssNames } from "../../utils";
import type { IconProps } from "../icon";
import { Icon } from "../icon";
@ -23,13 +22,6 @@ export function UpdateButton({ warningLevel, update, id }: UpdateButtonProps) {
const menuIconProps: IconProps = { material: "update", small: true };
const [opened, setOpened] = useState(false);
const onKeyDown = (evt: React.KeyboardEvent<HTMLButtonElement>) => {
if (evt.code == "Space") {
evt.preventDefault();
toggle();
}
};
const toggle = () => {
setOpened(!opened);
};
@ -47,8 +39,6 @@ export function UpdateButton({ warningLevel, update, id }: UpdateButtonProps) {
[styles.warningHigh]: warningLevel === "high",
[styles.warningMedium]: warningLevel === "medium",
})}
onClick={toggle}
onKeyDown={onKeyDown}
>
Update
<Icon material="arrow_drop_down" className={styles.icon}/>
@ -58,7 +48,7 @@ export function UpdateButton({ warningLevel, update, id }: UpdateButtonProps) {
htmlFor={buttonId}
isOpen={opened}
close={toggle}
open={noop}
open={toggle}
>
<MenuItem icon={menuIconProps} onClick={update} data-testid="update-lens-menu-item">
Relaunch to Update Lens