|
1 | | -import React, { forwardRef, type RefAttributes, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'; |
| 1 | +import React, { |
| 2 | + forwardRef, |
| 3 | + type RefAttributes, |
| 4 | + useEffect, |
| 5 | + useImperativeHandle, |
| 6 | + useMemo, |
| 7 | + useRef, |
| 8 | + useState, |
| 9 | +} from 'react'; |
2 | 10 | import classNames from 'classnames'; |
3 | 11 | import { pick } from 'lodash-es'; |
4 | 12 |
|
5 | 13 | import log from '@tdesign/common-js/log/index'; |
6 | | -import { getIEVersion, isChromium } from '@tdesign/common-js/utils/helper'; |
| 14 | +import { getIEVersion, isFirefox, isSafari } from '@tdesign/common-js/utils/helper'; |
7 | 15 | import Affix, { type AffixRef } from '../affix'; |
8 | 16 | import useDefaultProps from '../hooks/useDefaultProps'; |
9 | 17 | import useElementLazyRender from '../hooks/useElementLazyRender'; |
@@ -52,6 +60,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref) |
52 | 60 | } = props; |
53 | 61 |
|
54 | 62 | const borderWidth = props.bordered ? 1 : 0; |
| 63 | + const notFirefoxOrSafari = !isFirefox() && !isSafari(); |
55 | 64 |
|
56 | 65 | const tableRef = useRef<HTMLDivElement>(null); |
57 | 66 | const tableElmRef = useRef<HTMLTableElement>(null); |
@@ -309,15 +318,15 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref) |
309 | 318 | width: formatCSSUnit((isFixedHeader || resizable ? thWidthList.current[col.colKey] : undefined) || col.width), |
310 | 319 | }; |
311 | 320 | if (col.minWidth) { |
312 | | - if (isChromium()) { |
| 321 | + if (notFirefoxOrSafari) { |
313 | 322 | style.minWidth = formatCSSUnit(col.minWidth); |
314 | 323 | } else { |
315 | 324 | style.width = formatCSSUnit(col.minWidth); |
316 | 325 | } |
317 | 326 | } |
318 | 327 | // 没有设置任何宽度的场景下,需要保留表格正常显示的最小宽度,否则会出现因宽度过小的抖动问题 |
319 | 328 | if (!style.width && !col.minWidth && props.tableLayout === 'fixed') { |
320 | | - if (isChromium()) { |
| 329 | + if (notFirefoxOrSafari) { |
321 | 330 | style.minWidth = '80px'; |
322 | 331 | } else { |
323 | 332 | // 非 Chromium 内核浏览器中,min-width 兼容性差 |
@@ -525,10 +534,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref) |
525 | 534 | className={classNames(tableElmClasses)} |
526 | 535 | style={{ |
527 | 536 | ...tableElementStyles, |
528 | | - width: |
529 | | - resizable && isWidthOverflow && tableElmWidth |
530 | | - ? `${tableElmWidth}px` |
531 | | - : tableElementStyles.width, |
| 537 | + width: resizable && isWidthOverflow && tableElmWidth ? `${tableElmWidth}px` : tableElementStyles.width, |
532 | 538 | }} |
533 | 539 | > |
534 | 540 | {renderColGroup(false)} |
|
0 commit comments