Skip to content

Commit 290c411

Browse files
committed
Update ControlPlanesListMenu.tsx
1 parent 24da70c commit 290c411

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/components/ControlPlanes/ControlPlanesListMenu.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import { Button, Menu, MenuItem } from '@ui5/webcomponents-react';
2-
1+
import {
2+
Button,
3+
ButtonDomRef,
4+
Menu,
5+
MenuItem,
6+
Ui5CustomEvent,
7+
MenuDomRef,
8+
} from '@ui5/webcomponents-react';
9+
import type { ButtonClickEventDetail } from '@ui5/webcomponents/dist/Button.js';
310
import { Dispatch, FC, SetStateAction, useRef, useState } from 'react';
411
import '@ui5/webcomponents-icons/dist/copy';
512
import '@ui5/webcomponents-icons/dist/accept';
@@ -15,32 +22,32 @@ export const ControlPlanesListMenu: FC<ControlPlanesListMenuProps> = ({
1522
setDialogDeleteWsIsOpen,
1623
setIsCreateManagedControlPlaneWizardOpen,
1724
}) => {
18-
const popoverRef = useRef(null);
25+
const popoverRef = useRef<MenuDomRef>(null);
1926
const [open, setOpen] = useState(false);
2027

2128
const { t } = useTranslation();
2229

23-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
24-
const handleOpenerClick = (e: any) => {
25-
if (popoverRef.current) {
26-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27-
const ref = popoverRef.current as any;
28-
ref.opener = e.target;
30+
const handleOpenerClick = (
31+
e: Ui5CustomEvent<ButtonDomRef, ButtonClickEventDetail>,
32+
) => {
33+
if (popoverRef.current && e.currentTarget) {
34+
popoverRef.current.opener = e.currentTarget as HTMLElement;
2935
setOpen((prev) => !prev);
3036
}
3137
};
3238

3339
return (
3440
<>
35-
<Button icon="overflow" icon-end onClick={handleOpenerClick}></Button>
41+
<Button icon="overflow" icon-end onClick={handleOpenerClick} />
3642
<Menu
3743
ref={popoverRef}
3844
open={open}
3945
onItemClick={(event) => {
40-
if (event.detail.item.dataset.action === 'newManagedControlPlane') {
46+
const action = (event.detail.item as HTMLElement).dataset.action;
47+
if (action === 'newManagedControlPlane') {
4148
setIsCreateManagedControlPlaneWizardOpen(true);
4249
}
43-
if (event.detail.item.dataset.action === 'deleteWorkspace') {
50+
if (action === 'deleteWorkspace') {
4451
setDialogDeleteWsIsOpen(true);
4552
}
4653

0 commit comments

Comments
 (0)