Skip to content

Commit

Permalink
fix(data-table): fix cannot click selection checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
jiazan-wen committed Feb 14, 2022
1 parent dc65230 commit a501c29
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Fix `n-switch` can't use keyboard operation when checked value is customized.
- Fix `n-data-table`'s fixed column is covered by scroll content when placed inside popover.
- Fix `n-data-table` cannot click selection checkbox if the selection column is a column's child.

### Feats

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- 修复 `n-switch` 在自定义选中值的时候无法使用键盘操作
- 修复 `n-data-table` 放在 popover 内使用固定列滚动内容覆盖
- 修复 `n-data-table` 当 selection column 为某个 column 的子 column 时无法点击全选复选框

### Feats

Expand Down
20 changes: 13 additions & 7 deletions src/data-table/src/use-table-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ export function useTableData (
}
) {
const selectionColumnRef = computed<TableSelectionColumn | null>(() => {
return (
(props.columns.find((col) => {
if (col.type === 'selection') {
return true
const getSelectionColumn = (
cols: typeof props.columns
): TableSelectionColumn | null => {
for (let i = 0; i < cols.length; ++i) {
const col = cols[i]
if ('children' in col) {
return getSelectionColumn(col.children)
} else if (col.type === 'selection') {
return col
}
return false
}) as TableSelectionColumn | undefined) || null
)
}
return null
}
return getSelectionColumn(props.columns)
})

const treeMateRef = computed(() => {
Expand Down

0 comments on commit a501c29

Please sign in to comment.