@@ -49,6 +49,17 @@ type CompositeBarViewProps = CompositeBarProps & {
49
49
collapseItems ?: MenuItem [ ] ;
50
50
} ;
51
51
52
+ function getTime ( ) {
53
+ const now = new Date ( ) ;
54
+ const hours = String ( now . getHours ( ) ) . padStart ( 2 , '0' ) ;
55
+ const minutes = String ( now . getMinutes ( ) ) . padStart ( 2 , '0' ) ;
56
+ const seconds = String ( now . getSeconds ( ) ) . padStart ( 2 , '0' ) ;
57
+ const milliseconds = String ( now . getMilliseconds ( ) ) . padStart ( 3 , '0' ) ;
58
+
59
+ const formattedTime = `${ hours } :${ minutes } :${ seconds } .${ milliseconds } ` ;
60
+ return formattedTime ;
61
+ }
62
+
52
63
const CompositeBarView : FC < CompositeBarViewProps > = ( {
53
64
type,
54
65
items,
@@ -68,6 +79,38 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
68
79
} = useContext ( MultipleTooltipContext ) ;
69
80
const { compact} = useAsideHeaderContext ( ) ;
70
81
82
+ const handleTransitionRun = React . useCallback < ( e : TransitionEvent ) => void > (
83
+ ( e ) => {
84
+ if ( e . target ) {
85
+ const computedStyle = getComputedStyle ( e . target as HTMLElement ) ;
86
+ const isHovered = computedStyle . transform !== 'none' ;
87
+ console . log ( 'isHovered=' , isHovered , getTime ( ) ) ;
88
+ if ( ! isHovered && multipleTooltip && multipleTooltipActive ) {
89
+ setMultipleTooltipContextValue ( { active : false } ) ;
90
+ }
91
+ }
92
+ } ,
93
+ [ multipleTooltip , multipleTooltipActive ] ,
94
+ ) ;
95
+
96
+ React . useEffect ( ( ) => {
97
+ if ( ref . current ?. refContainer . current ?. node ) {
98
+ const listNode = ref . current . refContainer . current . node as HTMLElement ;
99
+ // this hack allow to detect hover events on element like browser css engine
100
+ listNode . style . setProperty ( 'transition' , 'transform 0.001ms step-start' ) ;
101
+ listNode . style . setProperty ( 'transition-behavior' , 'allow-discrete' ) ;
102
+ listNode . addEventListener ( 'transitionrun' , handleTransitionRun ) ;
103
+
104
+ return ( ) => {
105
+ listNode . removeEventListener ( 'transitionrun' , handleTransitionRun ) ;
106
+ listNode . style . removeProperty ( 'transition-behavior' ) ;
107
+ listNode . style . removeProperty ( 'transition' ) ;
108
+ } ;
109
+ }
110
+
111
+ return ;
112
+ } , [ ] ) ;
113
+
71
114
React . useEffect ( ( ) => {
72
115
function handleBlurWindow ( ) {
73
116
if ( multipleTooltip && multipleTooltipActive ) {
@@ -93,7 +136,6 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
93
136
activeIndex !== lastClickedItemIndex &&
94
137
e . clientX <= ASIDE_HEADER_COMPACT_WIDTH
95
138
) {
96
- console . log ( `onTooltipMouseEnter: active=true` ) ;
97
139
setMultipleTooltipContextValue ?.( {
98
140
active : true ,
99
141
} ) ;
@@ -119,7 +161,6 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
119
161
debounce (
120
162
( ) => {
121
163
if ( multipleTooltip && multipleTooltipActive && document . hasFocus ( ) ) {
122
- console . log ( `onTooltipMouseLeave: active=false` ) ;
123
164
setMultipleTooltipContextValue ?.( {
124
165
active : false ,
125
166
lastClickedItemIndex : undefined ,
@@ -139,7 +180,6 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
139
180
( itemIndex : number ) =>
140
181
debounce (
141
182
( ) => {
142
- console . log ( `onMouseEnterByIndex: itemIndex=${ itemIndex } ` ) ;
143
183
if ( multipleTooltip && document . hasFocus ( ) ) {
144
184
let multipleTooltipActiveValue = multipleTooltipActive ;
145
185
if ( ! multipleTooltipActive && itemIndex !== lastClickedItemIndex ) {
@@ -149,10 +189,8 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
149
189
activeIndex === itemIndex &&
150
190
multipleTooltipActive === multipleTooltipActiveValue
151
191
) {
152
- console . log ( 'onMouseEnterByIndex: skip change' ) ;
153
192
return ;
154
193
}
155
- console . log ( `onMouseEnterByIndex: set active=${ itemIndex } ` ) ;
156
194
setMultipleTooltipContextValue ( {
157
195
activeIndex : itemIndex ,
158
196
active : multipleTooltipActiveValue ,
@@ -183,7 +221,6 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
183
221
multipleTooltip &&
184
222
( activeIndex !== undefined || lastClickedItemIndex !== undefined )
185
223
) {
186
- console . log ( 'onMouseLeave: deactivate tooltip' ) ;
187
224
setMultipleTooltipContextValue ( {
188
225
activeIndex : undefined ,
189
226
lastClickedItemIndex : undefined ,
@@ -239,6 +276,7 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
239
276
onMouseLeave = { onTooltipMouseLeave }
240
277
>
241
278
< List < CompositeBarItem >
279
+ className = { b ( 'list' ) }
242
280
ref = { ref }
243
281
items = { items }
244
282
selectedItemIndex = { type === 'menu' ? getSelectedItemIndex ( items ) : undefined }
@@ -249,7 +287,6 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
249
287
filterable = { false }
250
288
sortable = { false }
251
289
renderItem = { ( item , _isItemActive , itemIndex ) => {
252
- // console.log('renderItem: ', itemIndex);
253
290
const itemExtraProps = isMenuItem ( item ) ? { item} : item ;
254
291
const enableTooltip = isMenuItem ( item )
255
292
? ! multipleTooltip
0 commit comments