1
1
import classNames from '../../_util/classNames' ;
2
- import { filterEmpty , flattenChildren , isValidElement } from '../../_util/props-util' ;
2
+ import { filterEmpty , findDOMNode , flattenChildren , isValidElement } from '../../_util/props-util' ;
3
3
import type { CSSProperties , VNodeArrayChildren } from 'vue' ;
4
- import { Text , computed , defineComponent , isVNode } from 'vue' ;
4
+ import { watch , shallowRef , Text , computed , defineComponent , isVNode } from 'vue' ;
5
5
6
6
import type {
7
7
DataIndex ,
@@ -24,6 +24,7 @@ import { warning } from '../../vc-util/warning';
24
24
import type { MouseEventHandler } from '../../_util/EventInterface' ;
25
25
import eagerComputed from '../../_util/eagerComputed' ;
26
26
import { customRenderSlot } from '../../_util/vnode' ;
27
+ import { addClass , removeClass } from '../../vc-util/Dom/class' ;
27
28
28
29
/** Check if cell is in hover range */
29
30
function inHoverRange ( cellStartRow : number , cellRowSpan : number , startRow : number , endRow : number ) {
@@ -157,6 +158,17 @@ export default defineComponent<CellProps>({
157
158
return vnode ;
158
159
}
159
160
} ;
161
+
162
+ const hoverRef = shallowRef ( null ) ;
163
+ watch ( [ hovering , ( ) => props . prefixCls , hoverRef ] , ( ) => {
164
+ const cellDom = findDOMNode ( hoverRef . value ) ;
165
+ if ( ! cellDom ) return ;
166
+ if ( hovering . value ) {
167
+ addClass ( cellDom , `${ props . prefixCls } -cell-row-hover` ) ;
168
+ } else {
169
+ removeClass ( cellDom , `${ props . prefixCls } -cell-row-hover` ) ;
170
+ }
171
+ } ) ;
160
172
return ( ) => {
161
173
const {
162
174
prefixCls,
@@ -334,7 +346,6 @@ export default defineComponent<CellProps>({
334
346
[ `${ cellPrefixCls } -with-append` ] : appendNode ,
335
347
[ `${ cellPrefixCls } -fix-sticky` ] :
336
348
( isFixLeft || isFixRight ) && isSticky && supportSticky . value ,
337
- [ `${ cellPrefixCls } -row-hover` ] : ! cellProps && hovering . value ,
338
349
} ,
339
350
additionalProps . class ,
340
351
cellClassName ,
@@ -347,7 +358,7 @@ export default defineComponent<CellProps>({
347
358
} ;
348
359
349
360
return (
350
- < Component { ...componentProps } >
361
+ < Component { ...componentProps } ref = { hoverRef } >
351
362
{ appendNode }
352
363
{ childNode }
353
364
{ slots . dragHandle ?.( ) }
0 commit comments