Skip to content

Commit ccffb9a

Browse files
committed
fix: use exclusion-based browser detection
1 parent eb5b706 commit ccffb9a

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

packages/components/table/BaseTable.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
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';
210
import classNames from 'classnames';
311
import { pick } from 'lodash-es';
412

513
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';
715
import Affix, { type AffixRef } from '../affix';
816
import useDefaultProps from '../hooks/useDefaultProps';
917
import useElementLazyRender from '../hooks/useElementLazyRender';
@@ -52,6 +60,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
5260
} = props;
5361

5462
const borderWidth = props.bordered ? 1 : 0;
63+
const notFirefoxOrSafari = !isFirefox() && !isSafari();
5564

5665
const tableRef = useRef<HTMLDivElement>(null);
5766
const tableElmRef = useRef<HTMLTableElement>(null);
@@ -309,15 +318,15 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
309318
width: formatCSSUnit((isFixedHeader || resizable ? thWidthList.current[col.colKey] : undefined) || col.width),
310319
};
311320
if (col.minWidth) {
312-
if (isChromium()) {
321+
if (notFirefoxOrSafari) {
313322
style.minWidth = formatCSSUnit(col.minWidth);
314323
} else {
315324
style.width = formatCSSUnit(col.minWidth);
316325
}
317326
}
318327
// 没有设置任何宽度的场景下,需要保留表格正常显示的最小宽度,否则会出现因宽度过小的抖动问题
319328
if (!style.width && !col.minWidth && props.tableLayout === 'fixed') {
320-
if (isChromium()) {
329+
if (notFirefoxOrSafari) {
321330
style.minWidth = '80px';
322331
} else {
323332
// 非 Chromium 内核浏览器中,min-width 兼容性差
@@ -525,10 +534,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
525534
className={classNames(tableElmClasses)}
526535
style={{
527536
...tableElementStyles,
528-
width:
529-
resizable && isWidthOverflow && tableElmWidth
530-
? `${tableElmWidth}px`
531-
: tableElementStyles.width,
537+
width: resizable && isWidthOverflow && tableElmWidth ? `${tableElmWidth}px` : tableElementStyles.width,
532538
}}
533539
>
534540
{renderColGroup(false)}

0 commit comments

Comments
 (0)