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): The filter will not take effect when the filterOptions value is 0 #2395

Merged
merged 2 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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` when the `filterOptions` value is 0, the filter will not take effect.

### 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` 当 `filterOptions` 值为 0 时过滤不生效

### Feats

Expand Down
2 changes: 1 addition & 1 deletion src/data-table/src/use-table-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function useTableData (
columnsWithControlledFilter.forEach((column) => {
if (column.type === 'selection' || column.type === 'expand') return
controlledFilterState[column.key] =
column.filterOptionValues || column.filterOptionValue || null
column.filterOptionValues ?? column.filterOptionValue ?? null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实还是有点问题,得用 undefined 来拦截,null 应该是受控的,就刻意为空

})
const activeFilters = Object.assign(
createShallowClonedObject(uncontrolledFilterStateRef.value),
Expand Down