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';
7474import StickyScrollBar from './stickyScrollBar' ;
7575import Column from './sugar/Column' ;
7676import ColumnGroup from './sugar/ColumnGroup' ;
77- import { getColumnsKey , validateValue } from './utils/valueUtil' ;
77+ import { getColumnsKey , validateValue , validNumberValue } from './utils/valueUtil' ;
7878import { getDOM } from 'rc-util/lib/Dom/findDOMNode' ;
7979
8080export const DEFAULT_PREFIX = 'rc-table' ;
@@ -331,12 +331,8 @@ function Table<RecordType extends DefaultRecordType>(
331331 if ( scrollBodyRef . current instanceof HTMLElement ) {
332332 // Native scroll
333333 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 } ) ;
340336 } else {
341337 const mergedKey = key ?? getRowKey ( mergedData [ index ] ) ;
342338 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>[]
3636export function validateValue < T > ( val : T ) {
3737 return val !== null && val !== undefined ;
3838}
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