diff --git a/.changeset/fresh-bananas-double.md b/.changeset/fresh-bananas-double.md new file mode 100644 index 000000000..3484b4eee --- /dev/null +++ b/.changeset/fresh-bananas-double.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/table": patch +--- + +fix: 修复 Safari 中设置 virtual 后只能表头滚动问题 diff --git a/.changeset/ninety-colts-heal.md b/.changeset/ninety-colts-heal.md new file mode 100644 index 000000000..ba4cd2034 --- /dev/null +++ b/.changeset/ninety-colts-heal.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +fix(table): 修复 Safari 中设置 virtual 后只能表头滚动问题 diff --git a/packages/ui/table/src/TableBody.tsx b/packages/ui/table/src/TableBody.tsx index 1cc8f020c..362d32297 100644 --- a/packages/ui/table/src/TableBody.tsx +++ b/packages/ui/table/src/TableBody.tsx @@ -1,4 +1,4 @@ -import React, { forwardRef, useCallback, useMemo, useState } from 'react' +import React, { forwardRef, useCallback, useEffect, useMemo, useState } from 'react' import VirtualList from 'rc-virtual-list' import { cx, getPrefixCls } from '@hi-ui/classname' import { __DEV__ } from '@hi-ui/env' @@ -31,6 +31,7 @@ export const TableBody = forwardRef( virtual, measureRowElementRef, scrollbar, + scrollLeft, } = useTableContext() const cls = cx(`${prefixCls}-body`) @@ -49,21 +50,12 @@ export const TableBody = forwardRef( } ) - const [scrollLeft, setScrollLeft] = useState(0) const rowWidth = useMemo(() => { let tmpWidth = 0 colWidths.forEach((width) => (tmpWidth += width)) return tmpWidth }, [colWidths]) - const onVirtualContainerScroll = useCallback( - (evt: any) => { - setScrollLeft(scrollBodyElementRef?.current?.scrollLeft || 0) - onTableBodyScroll(evt) - }, - [scrollBodyElementRef, onTableBodyScroll] - ) - if (virtual) { // TODO: avg和summay row的逻辑 @@ -78,7 +70,7 @@ export const TableBody = forwardRef(
( >
{isArrayNonEmpty(transitionData) ? (