Skip to content

Commit 9086ed1

Browse files
committed
chore: do not hide pdisk and vdisk popups if mouse on popup content
1 parent 5ecaecb commit 9086ed1

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

src/components/PDiskPopup/PDiskPopup.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ export const PDiskPopup = ({data, ...props}: PDiskPopupProps) => {
7070
const nodeHost = valueIsDefined(data.NodeId) ? nodeHostsMap?.get(data.NodeId) : undefined;
7171
const info = React.useMemo(() => preparePDiskData(data, nodeHost), [data, nodeHost]);
7272

73+
const [isPopupOpen, setIsPopupOpen] = React.useState(props.open);
74+
const onMouseLeave = React.useCallback(() => {
75+
setIsPopupOpen(false);
76+
}, []);
77+
const onMouseEnter = React.useCallback(() => {
78+
setIsPopupOpen(true);
79+
}, []);
80+
7381
return (
7482
<Popup
7583
contentClassName={b()}
@@ -78,7 +86,10 @@ export const PDiskPopup = ({data, ...props}: PDiskPopupProps) => {
7886
// bigger offset for easier switching to neighbour nodes
7987
// matches the default offset for popup with arrow out of a sense of beauty
8088
offset={[0, 12]}
89+
onMouseLeave={onMouseLeave}
90+
onMouseEnter={onMouseEnter}
8191
{...props}
92+
open={isPopupOpen || props.open}
8293
>
8394
<InfoViewer title="PDisk" info={info} size="s" />
8495
</Popup>

src/components/VDisk/VDisk.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22

3+
import {debounce} from 'lodash';
4+
35
import {STRUCTURE} from '../../containers/Node/NodePages';
46
import routes, {createHref, getVDiskPagePath} from '../../routes';
57
import {useDiskPagesAvailable} from '../../store/reducers/capabilities/hooks';
@@ -15,6 +17,8 @@ import './VDisk.scss';
1517

1618
const b = cn('ydb-vdisk-component');
1719

20+
const DEBOUNCE_TIMEOUT = 100;
21+
1822
export interface VDiskProps {
1923
data?: PreparedVDisk;
2024
compact?: boolean;
@@ -52,6 +56,9 @@ export const VDisk = ({
5256
onHidePopup?.();
5357
};
5458

59+
const debouncedHandleShowPopup = debounce(handleShowPopup, DEBOUNCE_TIMEOUT);
60+
const debouncedHandleHidePopup = debounce(handleHidePopup, DEBOUNCE_TIMEOUT);
61+
5562
let vDiskPath: string | undefined;
5663

5764
if (
@@ -77,8 +84,8 @@ export const VDisk = ({
7784
<div
7885
className={b()}
7986
ref={anchor}
80-
onMouseEnter={handleShowPopup}
81-
onMouseLeave={handleHidePopup}
87+
onMouseEnter={debouncedHandleShowPopup}
88+
onMouseLeave={debouncedHandleHidePopup}
8289
>
8390
<InternalLink to={vDiskPath} className={b('content')}>
8491
<DiskStateProgressBar

src/components/VDiskPopup/VDiskPopup.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ interface VDiskPopupProps extends PopupProps {
133133

134134
export const VDiskPopup = ({data, ...props}: VDiskPopupProps) => {
135135
const isFullData = isFullVDiskData(data);
136+
const [isPopupOpen, setIsPopupOpen] = React.useState(props.open);
137+
const onMouseLeave = React.useCallback(() => {
138+
setIsPopupOpen(false);
139+
}, []);
140+
const onMouseEnter = React.useCallback(() => {
141+
setIsPopupOpen(true);
142+
}, []);
136143

137144
const vdiskInfo = React.useMemo(
138145
() => (isFullData ? prepareVDiskData(data) : prepareUnavailableVDiskData(data)),
@@ -154,7 +161,10 @@ export const VDiskPopup = ({data, ...props}: VDiskPopupProps) => {
154161
// bigger offset for easier switching to neighbour nodes
155162
// matches the default offset for popup with arrow out of a sense of beauty
156163
offset={[0, 12]}
164+
onMouseEnter={onMouseEnter}
165+
onMouseLeave={onMouseLeave}
157166
{...props}
167+
open={isPopupOpen || props.open}
158168
>
159169
{data.DonorMode && <Label className={b('donor-label')}>Donor</Label>}
160170
<InfoViewer title="VDisk" info={vdiskInfo} size="s" />

src/containers/Storage/PDisk/PDisk.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22

3+
import {debounce} from 'lodash';
4+
35
import {DiskStateProgressBar} from '../../../components/DiskStateProgressBar/DiskStateProgressBar';
46
import {InternalLink} from '../../../components/InternalLink';
57
import {PDiskPopup} from '../../../components/PDiskPopup/PDiskPopup';
@@ -17,6 +19,8 @@ import './PDisk.scss';
1719

1820
const b = cn('pdisk-storage');
1921

22+
const DEBOUNCE_TIMEOUT = 100;
23+
2024
interface PDiskProps {
2125
data?: PreparedPDisk;
2226
vDisks?: PreparedVDisk[];
@@ -57,6 +61,9 @@ export const PDisk = ({
5761
onHidePopup?.();
5862
};
5963

64+
const debouncedHandleShowPopup = debounce(handleShowPopup, DEBOUNCE_TIMEOUT);
65+
const debouncedHandleHidePopup = debounce(handleHidePopup, DEBOUNCE_TIMEOUT);
66+
6067
const renderVDisks = () => {
6168
if (!vDisks?.length) {
6269
return null;
@@ -105,8 +112,8 @@ export const PDisk = ({
105112
<InternalLink
106113
to={pDiskPath}
107114
className={b('content')}
108-
onMouseEnter={handleShowPopup}
109-
onMouseLeave={handleHidePopup}
115+
onMouseEnter={debouncedHandleShowPopup}
116+
onMouseLeave={debouncedHandleHidePopup}
110117
>
111118
<DiskStateProgressBar
112119
diskAllocatedPercent={data.AllocatedPercent}

0 commit comments

Comments
 (0)