File tree Expand file tree Collapse file tree 4 files changed +39
-4
lines changed Expand file tree Collapse file tree 4 files changed +39
-4
lines changed Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff line change 11import React from 'react' ;
22
3+ import { debounce } from 'lodash' ;
4+
35import { STRUCTURE } from '../../containers/Node/NodePages' ;
46import routes , { createHref , getVDiskPagePath } from '../../routes' ;
57import { useDiskPagesAvailable } from '../../store/reducers/capabilities/hooks' ;
@@ -15,6 +17,8 @@ import './VDisk.scss';
1517
1618const b = cn ( 'ydb-vdisk-component' ) ;
1719
20+ const DEBOUNCE_TIMEOUT = 100 ;
21+
1822export 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
Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ interface VDiskPopupProps extends PopupProps {
133133
134134export 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" />
Original file line number Diff line number Diff line change 11import React from 'react' ;
22
3+ import { debounce } from 'lodash' ;
4+
35import { DiskStateProgressBar } from '../../../components/DiskStateProgressBar/DiskStateProgressBar' ;
46import { InternalLink } from '../../../components/InternalLink' ;
57import { PDiskPopup } from '../../../components/PDiskPopup/PDiskPopup' ;
@@ -17,6 +19,8 @@ import './PDisk.scss';
1719
1820const b = cn ( 'pdisk-storage' ) ;
1921
22+ const DEBOUNCE_TIMEOUT = 100 ;
23+
2024interface 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 }
You can’t perform that action at this time.
0 commit comments