Skip to content

Commit

Permalink
fix(SearchTable): resolve the issue of no width in the header when th…
Browse files Browse the repository at this point in the history
…e rowSelection attribute exists and the data source is empty
  • Loading branch information
Barrior committed Oct 30, 2024
1 parent 91d9c68 commit c9839db
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/search-table-react/src/SearchTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import RootContext from './RootContext'
import type { IGlobalState, ISearchTableProps, ISearchTableRef } from './typings/index.d'
import type { ITableProps } from './typings/table'

const { classNames, isPlainObject } = utils
const { classNames, isPlainObject, isNil } = utils

/**
* 备注:
Expand Down Expand Up @@ -56,6 +56,17 @@ const SearchTable = (
// 国际化处理
const internalLocale = useMemo(() => ({ ...zh_CN, ...locale }), [locale])

/**
* 解决存在 rowSelection 属性且数据源为空的情况下表头无宽度问题
* ref: https://github.com/ant-design/ant-design/issues/47114
*/
if (table.rowSelection && isNil(table.rowSelection.columnWidth)) {
table.rowSelection = {
...table.rowSelection,
columnWidth: 32,
}
}

/**
* 全局状态
*/
Expand Down Expand Up @@ -118,11 +129,6 @@ const SearchTable = (
// 总结栏处理
const { finalSummary } = useSummary({ table, finalColumns, summaryData })

// 组件加载完毕请求一次数据
useMounted(() => {
requestOnMounted && runRequest()
})

// 公共插槽参数
const comRenderParams = { loading }

Expand All @@ -138,6 +144,11 @@ const SearchTable = (
}
)

// 组件加载完毕请求一次数据
useMounted(() => {
requestOnMounted && runRequest()
})

// 开放 API
useOpenApi({
ref,
Expand Down

0 comments on commit c9839db

Please sign in to comment.