Skip to content

Commit ae115d9

Browse files
authored
fix(Storage): tune popups for vdisk and pdisk (#1883)
1 parent 1a833e3 commit ae115d9

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/components/HoverPopup/HoverPopup.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type HoverPopupProps = {
2020
anchorRef?: React.RefObject<HTMLElement>;
2121
onShowPopup?: VoidFunction;
2222
onHidePopup?: VoidFunction;
23+
delayOpen?: number;
24+
delayClose?: number;
2325
} & Pick<PopupProps, 'placement' | 'contentClassName'>;
2426

2527
export const HoverPopup = ({
@@ -32,6 +34,8 @@ export const HoverPopup = ({
3234
onHidePopup,
3335
placement = ['top', 'bottom'],
3436
contentClassName,
37+
delayClose = DEBOUNCE_TIMEOUT,
38+
delayOpen = DEBOUNCE_TIMEOUT,
3539
}: HoverPopupProps) => {
3640
const [isPopupVisible, setIsPopupVisible] = React.useState(false);
3741
const anchor = React.useRef<HTMLDivElement>(null);
@@ -41,8 +45,8 @@ export const HoverPopup = ({
4145
debounce(() => {
4246
setIsPopupVisible(true);
4347
onShowPopup?.();
44-
}, DEBOUNCE_TIMEOUT),
45-
[onShowPopup],
48+
}, delayOpen),
49+
[onShowPopup, delayOpen],
4650
);
4751

4852
const hidePopup = React.useCallback(() => {
@@ -51,8 +55,8 @@ export const HoverPopup = ({
5155
}, [onHidePopup]);
5256

5357
const debouncedHandleHidePopup = React.useMemo(
54-
() => debounce(hidePopup, DEBOUNCE_TIMEOUT),
55-
[hidePopup],
58+
() => debounce(hidePopup, delayClose),
59+
[hidePopup, delayClose],
5660
);
5761

5862
const onMouseEnter = debouncedHandleShowPopup;

src/components/VDisk/VDisk.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface VDiskProps {
1919
onShowPopup?: VoidFunction;
2020
onHidePopup?: VoidFunction;
2121
progressBarClassName?: string;
22+
delayOpen?: number;
23+
delayClose?: number;
2224
}
2325

2426
export const VDisk = ({
@@ -29,6 +31,8 @@ export const VDisk = ({
2931
onShowPopup,
3032
onHidePopup,
3133
progressBarClassName,
34+
delayClose,
35+
delayOpen,
3236
}: VDiskProps) => {
3337
const vDiskPath = getVDiskLink(data);
3438

@@ -38,6 +42,9 @@ export const VDisk = ({
3842
onShowPopup={onShowPopup}
3943
onHidePopup={onHidePopup}
4044
popupContent={<VDiskPopup data={data} />}
45+
offset={[0, 5]}
46+
delayClose={delayClose}
47+
delayOpen={delayOpen}
4148
>
4249
<div className={b()}>
4350
<InternalLink to={vDiskPath} className={b('content')}>

src/containers/Storage/PDisk/PDisk.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ export const PDisk = ({
5959
flexGrow: Number(vdisk.AllocatedSize) || 1,
6060
}}
6161
>
62-
<VDisk data={vdisk} inactive={!isVdiskActive(vdisk, viewContext)} compact />
62+
<VDisk
63+
data={vdisk}
64+
inactive={!isVdiskActive(vdisk, viewContext)}
65+
compact
66+
delayClose={200}
67+
delayOpen={200}
68+
/>
6369
</div>
6470
))}
6571
</div>
@@ -77,10 +83,12 @@ export const PDisk = ({
7783
{renderVDisks()}
7884
<HoverPopup
7985
showPopup={showPopup}
86+
offset={[0, 5]}
8087
anchorRef={anchorRef}
8188
onShowPopup={onShowPopup}
8289
onHidePopup={onHidePopup}
8390
popupContent={<PDiskPopup data={data} />}
91+
delayClose={200}
8492
>
8593
<InternalLink to={pDiskPath} className={b('content')}>
8694
<DiskStateProgressBar

0 commit comments

Comments
 (0)