Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(data-table): fix cannot click selection checkbox #2402

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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