File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ import Panel from './Panel';
74
74
import StickyScrollBar from './stickyScrollBar' ;
75
75
import Column from './sugar/Column' ;
76
76
import ColumnGroup from './sugar/ColumnGroup' ;
77
- import { getColumnsKey , validateValue } from './utils/valueUtil' ;
77
+ import { getColumnsKey , validateValue , validNumberValue } from './utils/valueUtil' ;
78
78
import { getDOM } from 'rc-util/lib/Dom/findDOMNode' ;
79
79
80
80
export const DEFAULT_PREFIX = 'rc-table' ;
@@ -331,12 +331,8 @@ function Table<RecordType extends DefaultRecordType>(
331
331
if ( scrollBodyRef . current instanceof HTMLElement ) {
332
332
// Native scroll
333
333
const { index, top, key } = config ;
334
-
335
- // * 考虑top为0的情况
336
- if ( top || top === 0 ) {
337
- scrollBodyRef . current ?. scrollTo ( {
338
- top,
339
- } ) ;
334
+ if ( validNumberValue ( top ) ) {
335
+ scrollBodyRef . current ?. scrollTo ( { top } ) ;
340
336
} else {
341
337
const mergedKey = key ?? getRowKey ( mergedData [ index ] ) ;
342
338
scrollBodyRef . current . querySelector ( `[data-row-key="${ mergedKey } "]` ) ?. scrollIntoView ( ) ;
Original file line number Diff line number Diff line change @@ -36,3 +36,7 @@ export function getColumnsKey<T = any>(columns: readonly GetColumnKeyColumn<T>[]
36
36
export function validateValue < T > ( val : T ) {
37
37
return val !== null && val !== undefined ;
38
38
}
39
+
40
+ export function validNumberValue ( value : any ) {
41
+ return typeof value === 'number' && ! Number . isNaN ( value ) ;
42
+ }
You can’t perform that action at this time.
0 commit comments