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

Table 是否受控的判断条件不包含 filtered #30003

Closed
1 task
Mongkii opened this issue Apr 1, 2021 · 3 comments · Fixed by #39883
Closed
1 task

Table 是否受控的判断条件不包含 filtered #30003

Mongkii opened this issue Apr 1, 2021 · 3 comments · Fixed by #39883
Labels

Comments

@Mongkii
Copy link
Contributor

Mongkii commented Apr 1, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://github.com/ant-design/ant-design/blob/HEAD/components/table/hooks/useFilter/index.tsx

Steps to reproduce

搜索:if (collectedStates.every(({ filteredKeys }) => filteredKeys === undefined)) {

What is expected?

if (collectedStates.every(({ filteredKeys, forceFiltered }) => (filteredKeys === undefined && forceFiltered === undefined))) {

What is actually happening?

if (collectedStates.every(({ filteredKeys }) => filteredKeys === undefined)) {

Environment Info
antd undefined
React 17.0.2
System macOS 10.14.5
Browser Chrome 89

Table 只通过 filteredKeys 判断是否受控,而不考虑 forceFiltered 字段,请问是有意为之吗?

@afc163
Copy link
Member

afc163 commented May 11, 2021

你遇到什么问题了么?

@Mongkii
Copy link
Contributor Author

Mongkii commented May 11, 2021

场景是:自行实现了一个筛选组件,该组件中的筛选状态能反映到表格中。即:通过直接设置 filtered 属性控制表格的「已筛选」状态

示例代码:

const [isFiltered, setIsFiltered] = useState(false);

const columns = [
  {
    filtered: isFiltered,
  },
];

但由于 issue 中的判断逻辑,我还必须额外设置 filteredValue,才能达到目的

const columns = [
  {
    filtered: isFiltered,
    filteredValue: [],
  },
];

比较好奇为什么不能仅仅设置 filtered,是出于什么设计的权衡吗

@qinghua5453
Copy link

场景是:自行实现了一个筛选组件,该组件中的筛选状态能反映到表格中。即:通过直接设置 filtered 属性控制表格的「已筛选」状态

示例代码:

const [isFiltered, setIsFiltered] = useState(false);

const columns = [
  {
    filtered: isFiltered,
  },
];

但由于 issue 中的判断逻辑,我还必须额外设置 filteredValue,才能达到目的

const columns = [
  {
    filtered: isFiltered,
    filteredValue: [],
  },
];

比较好奇为什么不能仅仅设置 filtered,是出于什么设计的权衡吗
你简直救了我的命啊,我就是没写那个filteredValue: [], 筛选active 死活多出现不了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants